PDA

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() ?

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

Thoughtgrid
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

jeffronald19
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.

damponting44
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.

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

traveloweb
01-11-2018, 02:05 AM
printf displays formatted output to the standard output device. It takes any number of parameters* and depending on various sequences in the first argument to it, gives you different formatted ouput.

sprintf does the exact same thing, except instead of displaying it to an output device, it stores that in a string you pass to it.

jackar56
01-12-2018, 05:23 AM
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.