From: Christoph B. <bar...@or...> - 2008-08-19 22:20:44
|
Am Dienstag, 19. August 2008 schrieb aruperez: > I'm using valgrind a in'm having a little problem, > > I'm using the function sprintf to convert an int to a char * > if you check the example how to use this function in www.cppreference.com > > there is something like this > char result[100]; > int num = 24; > sprintf( result, "%d", num ); > > however when i do that in my code, valgrind reports the following error > ==16490== Use of uninitialised value of size 4 > ==16490== at 0x43876E4: __printf_fp (in /lib/libc-2.6.1.so) > ==16490== by 0x4382FE0: vfprintf (in /lib/libc-2.6.1.so) > ==16490== by 0x439E91B: vsprintf (in /lib/libc-2.6.1.so) > ==16490== by 0x438A42D: sprintf (in /lib/libc-2.6.1.so) > > what should i do?? initialize the char[] before calling the function?, > which is the best way to do it becuase i tried assigning = "" but valgrind > still complained. Your example code looks ok. Show us the real code. Christoph |