sprintf or string handling problems
Posted: Sun Jul 13, 2008 1:48 am
I am trying to create a function ( based on the getclone2() idea ) but i am having inconsistent results
the function is cloneID() and is global
the idea is to use the resulting string in any other function, not just Getclone
eg:
but, I think I am doing something wrong with the string types I am using or something.. the executable version appears to work OK.. but in 'Game Mode' it has varying results ( works sometimes, others not.. ) or is it just my computer
which means I have to compile each time I want to test it..
any ideas?
thanks
the function is cloneID() and is global
- Code: Select all
char *cloneID(const char *cname, int cindex)
{
char buffer[50];
sprintf(buffer,"%s.%d",cname,cindex);
return buffer;
}
the idea is to use the resulting string in any other function, not just Getclone
eg:
- Code: Select all
int i;
for (i=4;i<11;i++)
{
DestroyActor(cloneID("test",i));
}
but, I think I am doing something wrong with the string types I am using or something.. the executable version appears to work OK.. but in 'Game Mode' it has varying results ( works sometimes, others not.. ) or is it just my computer
which means I have to compile each time I want to test it..
any ideas?
thanks