Pelles C forum
Pelles C => General discussions => Topic started by: post from old forum on September 13, 2004, 08:41:34 PM
-
char* format=" "; // 16 spaces
char* Result[22] ;
int p=12;
sprintf(format, "%%.%df", p);
sprintf(Result, format, *d);
what is wrong with the above code?
it crashes on my PC, any help is appreciated.
-
I think the problem is with the variable format. You initialize it with a literal string. In Pelles C (and several other C compilers), literal strings are put in read-only memory. Writing to read-only memory will cause an exception.
Pelle