Like Tree4Likes
  • 4 Post By WaltP

Return value of sscanf

This is a discussion on Return value of sscanf within the C Programming forums, part of the General Programming Boards category; Hello everyone, I wanna ask that what is the meaning of the return value of sscanf? I've seen people use ...

  1. #1
    Registered User
    Join Date
    Aug 2012
    Posts
    11

    Return value of sscanf

    Hello everyone, I wanna ask that what is the meaning of the return value of sscanf?

    I've seen people use sscanf return value to check their string..

    eg.
    Code:
    if( sscanf(string, "%d", &value) != 1 ){
        //Do something
    }
    cheers!

  2. #2
    Registered User
    Join Date
    Sep 2006
    Posts
    8,868
    All the scanf() family of functions, return the number of items that have been scanned, and stored.

  3. #3
    Registered User
    Join Date
    Aug 2012
    Posts
    11
    ah ok! thank you very much ^ ^

  4. #4
    Been here, done that.
    Join Date
    May 2003
    Posts
    1,161
    We should call GOOGLE and tell them that searching for scanf() doesn't seem to work...
    Definition: Politics -- Latin, from
    poly meaning many and
    tics meaning blood sucking parasites
    -- Tom Smothers

  5. #5
    qny
    qny is offline
    Registered User
    Join Date
    Sep 2012
    Posts
    355
    Do not google for C functions: you may hit a page with wrong information.

    Go to POSIX.1-2008 and look there
    The POSIX site has descriptions of some functions that are not in Standard C (and some content that is not Standard) but that is easily identified and filtered out when needed.

  6. #6
    Been here, done that.
    Join Date
    May 2003
    Posts
    1,161
    Quote Originally Posted by qny View Post
    Do not google for C functions: you may hit a page with wrong information.
    So because of one site we should not use Google? C'mon, get real. Google will give hundreds of sites. After checking one site, choose another two for verification. Takes a minute. Any discrepancies/confusion, check a couple more. If you decide a site gave bad information, you know not to check that site again. But to not use Google is ludicrous.

    Anyway, isn't the above what experts do? I know I do. If you don't, better start...
    Definition: Politics -- Latin, from
    poly meaning many and
    tics meaning blood sucking parasites
    -- Tom Smothers

  7. #7
    Registered User
    Join Date
    Sep 2006
    Posts
    8,868
    All I know is, I tried to get scanf() to return watermelons, or a good beer.

    It refused to cooperate!

    Google was no help whatsoever!

  8. #8
    Registered User
    Join Date
    Aug 2012
    Posts
    11
    I did try to search google, can't find a page that explains it.. or probably just missed the line o.O

    EDIT... well yes.. i guess i missed the line thanks anyways
    Last edited by dendeer82; 09-16-2012 at 07:57 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 1
    Last Post: 07-04-2007, 01:20 AM
  2. Replies: 12
    Last Post: 04-07-2007, 12:11 PM
  3. Replies: 6
    Last Post: 04-09-2006, 05:32 PM
  4. Replies: 4
    Last Post: 07-15-2005, 05:10 PM
  5. sscanf (I think)
    By RyeDunn in forum C Programming
    Replies: 7
    Last Post: 07-31-2002, 09:46 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21