by sairam rajagopalan on March 17th, 2006

sairam rajagopalan

Question

Help answer this question below.

In C, what is the difference between scanf and sscanf?

Answers. 2 helpful answers below.

  • by BigDaddyBS on March 11th, 2009

    BigDaddyBS

    See http://www.answerbag.com/q_view/46327
    (THIS one is a dupe question)

    No comments. Post one | Permalink

  • by RedJohn on March 17th, 2006

    RedJohn

    scanf (scan-formatted) reads characters from stdin, normally the keyboard unless redirected, while sscanf (string-scan-formatted) reads characters from a string in memory. This is quite handy when you want to read a user input string into memory and then parse it.

    From the Borland C++ User's Guide...

    scanf:
    Scans and formats input from the stdin stream.
    The scanf function:
    - scans a series of input fields one character at a time.
    - formats each field according to a corresponding format specifier passed in the format string *format.

    sscanf:
    Scans and formats input from a string.
    sscanf scans a series of input fields, one character at a time, reading from a string. Then each field is formatted according to a format specifier passed to sscanf in the format string pointed to by format. Finally, sscanf stores the formatted input at an address passed to it as an argument following format. There must be the same number of format specifiers and addresses as there are input fields.

    No comments. Post one | Permalink

Want to attach an image to your answer? Click here.

Did this answer your question? If not, then ask a new question or create a poll.

More Questions. Additional questions in this category.

You're reading In C, what is the difference between scanf and sscanf? - which can also be phrased in the following ways:

  • Differnce between in fscanf and sscanf

Follow us on Facebook!

Related Ads

ANSWERBAG BUZZ

What is sscanf
Difference between scanf and sscanf
Difference between gets and scanf
Difference between sscanf and scanf
Sscanf c language
Difference between scanf
C language sscanf
Sscanf language C
What is sscanf
What is difference between memcpy and sscanf