Results 1 to 8 of 8

Thread: What is the difference between printf() and sprintf() ?

  1. #1
    Registered
    Join Date
    Mar 2016
    Posts
    76

    What is the difference between printf() and sprintf() ?

    What is the difference between printf() and sprintf() ?

  2. #2
    Registered
    Join Date
    May 2016
    Posts
    39
    Printf() - Writes output to the standard out stream
    sprintf() - writes output to a buffer that you allocate

  3. #3
    Thoughtgrid Thoughtgrid's Avatar
    Join Date
    Jul 2016
    Location
    Bangalore
    Posts
    219
    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

  4. #4
    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.

  5. #5
    Registered
    Join Date
    Nov 2016
    Posts
    649
    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.

  6. #6

  7. #7
    Registered
    Join Date
    Jan 2018
    Posts
    66
    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.

  8. #8
    Registered
    Join Date
    Oct 2016
    Posts
    270
    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.
    Best Android Training | Devops Training | SQL Server Training and many more IT courses.

Similar Threads

  1. what is the difference between ppc and cpc
    By Nexevo Technologi in forum Search Engine Optimization
    Replies: 4
    Last Post: 04-21-2017, 03:54 AM
  2. What are the Difference between SMO and PPC
    By Nexevo Technologi in forum Search Engine Optimization
    Replies: 0
    Last Post: 12-01-2015, 05:10 AM
  3. What is the Difference between PPC and SMO
    By Nexevo Technologi in forum Search Engine Optimization
    Replies: 0
    Last Post: 09-30-2015, 08:12 AM
  4. .com, .net, .us and .info any difference?
    By organ in forum Search Engine Optimization
    Replies: 7
    Last Post: 04-26-2006, 12:01 AM
  5. Why the difference, adwords - overture?
    By dolphin in forum Advertising & Affiliate Programs
    Replies: 2
    Last Post: 08-13-2003, 06:32 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •