View Full Version : What is the difference between printf() and sprintf() ?

Shivangi Panwar
05-12-2016, 04:56 AM
What is the difference between printf() and sprintf() ?

07-02-2016, 04:14 AM
Printf() - Writes output to the standard out stream
sprintf() - writes output to a buffer that you allocate

09-26-2016, 10:51 PM
The printf function used to print character stream of data and stdout console
In the String print function is stead of printing on console store it on the char buffer that are specified in sprintf

12-27-2016, 10:08 PM
printf("format", args) is used to print the data onto the standard output which is often a computer monitor.

sprintf(char *, "format", args) is like printf. Instead on displaying the formated string on the standard output i.e. a monitor, it stores the formated data in a string pointed to by the char pointer (the very first parameter). The string location is the only difference between printf and sprint syntax.

01-17-2017, 12:43 AM
printf is equivalent to writing fprintf(stdout, ...) and writes formatted text to wherever the standard output stream is currently pointing. sprintf writes formatted text to an array of char , as opposed to a stream. sprintf(buffer,...) is used to format a string to a buffer.

02-06-2017, 05:01 AM
sprintf() and printf() is that sprintf() writes data into a character array