C Programming Absolute Beginner's Guide (3rd Edition)

(Romina) #1

Being able to process user input is an important part of any language. scanf()
performs data entry—that is, scanf() gets the user’s input and stores that input in
variables. Key concepts from this chapter include:



  • Use scanf() to get data from the user by way of the keyboard, and remember to
    include a control string to dictate how your data will look when input.

  • Before using a scanf(), use a printf() to prompt the user for the values and
    format you want.

  • Put an ampersand (&) before nonarray variables in a scanf().

  • Always add a leading space before the first control string character (as an example,
    " %d" contains a space before the %d) to ensure accurate character input.

Free download pdf