NO

Author Topic: need help with sprintf  (Read 8030 times)

post from old forum

  • Guest
need help with sprintf
« 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.

post from old forum

  • Guest
need help with sprintf
« Reply #1 on: September 13, 2004, 08:42:20 PM »
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