Thread: sscanf scanf

  1. #1
    Registered User
    Join Date
    Oct 2010
    Posts
    25

    sscanf scanf

    what is the different between scanf and sscanf
    one different that im not sure if im correct is that with sscanf you can you "\0" to find if the string has ended?

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,412
    Quote Originally Posted by ddimit02
    what is the different between scanf and sscanf
    Well...
    Quote Originally Posted by C99 Clause 7.19.6.4 Paragraph 1
    The scanf function is equivalent to fscanf with the argument stdin interposed before the arguments to scanf.
    Quote Originally Posted by C99 Clause 7.19.6.7 Paragraph 1
    The sscanf function is equivalent to fscanf, except that input is obtained from a string (specified by the argument s) rather than from a stream. Reaching the end of the string is equivalent to encountering end-of-file for the fscanf function.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  3. #3
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Quote Originally Posted by ddimit02 View Post
    what is the different between scanf and sscanf
    You could always just read the man pages. Or, any text on C for that matter. In short:

    scanf - read from standard input device
    sscanf - read from a string
    fscanf - read from a file stream


    Quzah.
    Hope is the first step on the road to disappointment.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Simple XOR Program
    By dolfaniss in forum C Programming
    Replies: 8
    Last Post: 05-24-2010, 01:27 PM
  2. Help with a basic scanf procedure.
    By killpoppop in forum C Programming
    Replies: 9
    Last Post: 11-03-2008, 04:39 PM
  3. scanf issue
    By fkheng in forum C Programming
    Replies: 6
    Last Post: 06-20-2003, 07:28 AM
  4. Scanf and integer...
    By penny in forum C Programming
    Replies: 3
    Last Post: 04-24-2003, 06:36 AM
  5. scanf - data is "put back" - screws up next scanf
    By voltson in forum C Programming
    Replies: 10
    Last Post: 10-14-2002, 04:34 AM