I must be insane or stupid, but either way I'm going out of my mind trying to figure out what I'm doing wrong.
I've got a simple little bitty function for creating a series of asterisks, variying by clan rank. The code is as follows:
char *show_rank(CHAR_DATA *ch)
{
int i = 0;
char buf[256];
buf[0] = '[';
if (ch->rank == 0)
{ strcat(buf, "]");
return buf;}
for (i = 1; i <= ch->rank; i++)
strcat(buf, "{R*{x");
strcat(buf, "]");
return buf;
}
I'm getting the following error during compile time:
handler.c:273: warning: function returns address of local variable
Now I understand why this happens, but I can't figure out how to get around it. I haven't dealt much with passing strings between functions, so I'm a bit clueless here. Anyone got a suggestion?
-Visko
|