Ok this might seem kinda a small problem but why can't I do this?
char *temp="Hello";
char *temp2;
sprintf(temp2, "%sWorld, temp);
Ok this might seem kinda a small problem but why can't I do this?
char *temp="Hello";
char *temp2;
sprintf(temp2, "%sWorld, temp);
Because temp2 is a pointer to char and doesn't have any space allocated for storage. Try char temp2[11]; instead.
You get the 11 from the length of temp plus the length of "World" plus 1 for the terminating 0.
Last edited by itsme86; 09-12-2004 at 01:18 AM.
If you understand what you're doing, you're not learning anything.
Well, you can do it, it just won't do what you want it to.Originally Posted by ExtremelyStupid
Quzah.
Hope is the first step on the road to disappointment.