Thread: sprintf returns random values upon unsuccessful conversion

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Feb 2019
    Posts
    1,078
    Quote Originally Posted by SergeP View Post
    scanf? How is it related to sprintf?
    If you read carefully the definition of printf() functions. All returns the number of printer characters. A negative value is returned only in case of "output error" (like using fprintf() and trying to write to an invalid stream). The only exception is snprintf() functions. They will return the number of characters that would be printed regardless of the size of the bufffer.

    scanf() will return the number of successful convertions.

  2. #2
    Registered User
    Join Date
    Dec 2019
    Posts
    10
    I see! It makes sense now.
    Gracias!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. atof returns weird values
    By Domo230 in forum C Programming
    Replies: 2
    Last Post: 03-27-2011, 06:27 AM
  2. what exactlly these values returns?
    By nkrao123@gmail. in forum C Programming
    Replies: 3
    Last Post: 12-09-2009, 06:42 AM
  3. scanf returns random character
    By giannisapi in forum C Programming
    Replies: 3
    Last Post: 06-20-2009, 12:06 PM
  4. fread returns strange values
    By seaking1 in forum C Programming
    Replies: 6
    Last Post: 04-30-2009, 02:10 AM
  5. sprintf values
    By darfader in forum C Programming
    Replies: 4
    Last Post: 10-23-2003, 06:40 AM

Tags for this Thread