Click here to Skip to main content
15,921,203 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: append a character to a char* Pin
moonraker92828-Jul-07 22:26
moonraker92828-Jul-07 22:26 
GeneralRe: append a character to a char* Pin
cp987628-Jul-07 22:49
cp987628-Jul-07 22:49 
GeneralRe: append a character to a char* Pin
moonraker92828-Jul-07 22:59
moonraker92828-Jul-07 22:59 
GeneralRe: append a character to a char* Pin
cp987628-Jul-07 23:45
cp987628-Jul-07 23:45 
GeneralRe: append a character to a char* Pin
moonraker92829-Jul-07 10:08
moonraker92829-Jul-07 10:08 
GeneralRe: append a character to a char* Pin
cp987629-Jul-07 12:59
cp987629-Jul-07 12:59 
GeneralRe: append a character to a char* Pin
moonraker92829-Jul-07 13:03
moonraker92829-Jul-07 13:03 
GeneralRe: append a character to a char* Pin
cp987629-Jul-07 13:36
cp987629-Jul-07 13:36 
If you are allocating such a short array you either have to be very careful that sprintf does not write past the end of the array (remembering the null terminator) or use the safe version. If sprintf writes past the end of the buffer you will get bugs that can be very hard to track down.

I can't find the limit of width using %f, but a quick test with printf("Pi = %f", 1000000000000*pi) gives "Pi = 3141592653589.793000" showing that the %f specifier can print 20 characters at least. So printing using %f to a buffer of length 10 using sprintf is dangerous at best.



Peter
"Until the invention of the computer, the machine gun was the device that enabled humans to make the most mistakes in the smallest amount of time."

GeneralRe: append a character to a char* Pin
User 58385229-Jul-07 18:34
User 58385229-Jul-07 18:34 
GeneralRe: append a character to a char* Pin
cp987629-Jul-07 19:08
cp987629-Jul-07 19:08 
GeneralRe: append a character to a char* Pin
David Crow30-Jul-07 4:12
David Crow30-Jul-07 4:12 
AnswerRe: append a character to a char* Pin
Mark Salsbery30-Jul-07 6:43
Mark Salsbery30-Jul-07 6:43 
GeneralRe: append a character to a char* Pin
moonraker92830-Jul-07 9:18
moonraker92830-Jul-07 9:18 
QuestionVC6.0 Compiler error. Pin
Eytukan28-Jul-07 7:01
Eytukan28-Jul-07 7:01 
AnswerRe: VC6.0 Compiler error. Pin
Mark Salsbery28-Jul-07 7:45
Mark Salsbery28-Jul-07 7:45 
GeneralRe: VC6.0 Compiler error. Pin
Eytukan28-Jul-07 7:50
Eytukan28-Jul-07 7:50 
GeneralRe: VC6.0 Compiler error. Pin
Mark Salsbery28-Jul-07 7:52
Mark Salsbery28-Jul-07 7:52 
GeneralRe: VC6.0 Compiler error. Pin
Randor 28-Jul-07 9:10
professional Randor 28-Jul-07 9:10 
GeneralRe: VC6.0 Compiler error. Pin
Paul Conrad28-Jul-07 10:32
professionalPaul Conrad28-Jul-07 10:32 
QuestionHow to rotate an icon? Pin
eli1502197928-Jul-07 5:15
eli1502197928-Jul-07 5:15 
AnswerRe: How to rotate an icon? Pin
Eytukan28-Jul-07 5:22
Eytukan28-Jul-07 5:22 
GeneralRe: How to rotate an icon? Pin
eli1502197928-Jul-07 5:28
eli1502197928-Jul-07 5:28 
GeneralRe: How to rotate an icon? Pin
Eytukan28-Jul-07 5:31
Eytukan28-Jul-07 5:31 
GeneralRe: How to rotate an icon? Pin
eli1502197928-Jul-07 5:38
eli1502197928-Jul-07 5:38 
GeneralRe: How to rotate an icon? Pin
Eytukan28-Jul-07 7:00
Eytukan28-Jul-07 7:00 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.