Hi,
quick answer: the case when she is female is
> for (count = 0; buf[count] != '\0'; count++);
which has an extraneous semicolon `;' at the end.
But since you are actually changing `$M' to `%s',
it seems like you want to use sprintf to achive this.
That would be like
if (buf[counter] == '$' && buf[counter + 1] == 'M')
{
buf[counter] = '%';
buf[counter + 1] = 's';
sprintf( buf2, buf, "it, her, him whatever" );
strcpy( buf, buf2 );
}
something to that extent.
But I would suggest you use pointers,
and it would make your code much easier to expand.
I don't program for ROM anymore,
but I just typed up some code just now and hope it works for you.
void whatever_function( char *format, [rest of your arguments] )
{
char buf[1024] = "";
char *paste = buf;
// you will start pasting characters to buf[0], paste will be
incremented
char *copy;
// points to whatever `string' you need to copy
while( *format != '\0' )
{
if( *format != '$' )
{
*(paste++) = *(format++);
continue;
} // format string ``You pout at $N, begging $M for some comfort.''
// is copied a charcater per loop if it is not `$'.
format++;
// if it is `$', we look at the next thing
switch( *format )
{
default:
copy = "???";
break;
case 'M':
copy = "her";
// add your check to your victim's sex here
break;
case 'N':
copy = "Jealosy";
// add the code to set `copy' to your victim's name
break;
// add more cases here whatever you need, just set the `copy' pointer.
// ...
}
while( *copy != '\0' )
{
*(paste++) = *(copy++);
}
// copy the `copy' string into wherever you were `paste'ing on the `buf'
char*
// this is where the copying _automatically_ takes place.
format++;
}
cout << buf;
// change it to whatever you need to display the string
}
That's it, you don't need to copy and paste tons of code for
each case (male, female, undeclared, etc) and furthermore,
each argument ( $N, $M, etc. ), just set *copy to point whatever
you want to copy to the location, break out of the `switch',
and let the code after the `switch' block take cares of the
copying.
I am not sure if this is how ROM does it, but at least
this will be much better than your way I think.
If other people know of better implementations of this,
please post. (Or maybe I ought to look at how ROM does this.)
Htam
----- Original Message -----
From: <[EMAIL PROTECTED]>
To: <[email protected]>
Sent: 2003.11.20 10:43
Subject: gocial $M problem
> Hey list, this is a new problem. Can someone point me in the right
direction in fixing this problem?
>
> (ofound) Target found, others see:
> You pout at $N, begging $M for some comfort.
>
> where $N is the name of the victim,
> and $M SHOULD be the sex of the victim. but it just bugs out an does the
following
>
> Gocial: Atm pouts at Jealousy, begging herGocial: Atm pouts at
> Jealousy, begging %s for some comfort.
>
> this is what i think the problems im not sure.
>
>
> else if (buf[counter] == '$' && buf[counter + 1] == 'M')
> {
> buf[counter] = '%';
> buf[counter + 1] = 's';
> switch (victim->sex)
> {
> default:
> strcpy(buf2,buf);
> buf2[counter] = '\0';
> strcat(buf2,"it");
> for (count = 0; buf[count] != '\0'; count++)
> {
> buf[count] = buf[count+counter+2];
> }
> strcat(buf2,buf);
> strcpy(buf,buf2);
> break;
> case 1:
> strcpy(buf2,buf);
> buf2[counter] = '\0';
> strcat(buf2,"him");
> for (count = 0; buf[count] != '\0'; count++)
> {
> buf[count] = buf[count+counter+2];
> }
> strcat(buf2,buf);
> strcpy(buf,buf2);
> break;
> case 2:
> strcpy(buf2,buf);
> buf2[counter] = '\0';
> strcat(buf2,"her");
> for (count = 0; buf[count] != '\0'; count++);
> {
> buf[count] = buf[count+counter+2];
> }
> strcat(buf2,buf);
> strcpy(buf,buf2);
> break;
> }
> }
>
>
> So what do you think list? thanks for any help or advice
> Atm!
>
>
> __________________________________________________________________
> McAfee VirusScan Online from the Netscape Network.
> Comprehensive protection for your entire computer. Get your free trial
today!
> http://channels.netscape.com/ns/computing/mcafee/index.jsp?promo=393397
>
> Get AOL Instant Messenger 5.1 free of charge. Download Now!
> http://aim.aol.com/aimnew/Aim/register.adp?promo=380455
>
> --
> ROM mailing list
> [email protected]
> http://www.rom.org/cgi-bin/mailman/listinfo/rom