August 2011
Intermediate to advanced
552 pages
23h 48m
English
The printf family of calls lives under standard / buffered I/O because they write out to FILE streams, either explicitly or implicitly. sprintf and snprintf write to a buffer, but they have the same syntax as their I/O companions.
int printf (const char *format, ...);
int fprintf (FILE *stream, const char *format, ...);
int sprintf (char *str, const char *format, ...);
int snprintf (char *str, size_t size, const char *format, ...);
int asprintf (char **ret, const char *format, ...);printf() writes to stdout. fprintf() writes to any FILE. sprintf() writes into a buffer, while snprintf() writes into a buffer but is given the amount of space it can write in. Always use snprintf() instead of sprintf(). There is no prevention of buffer ...
Read now
Unlock full access