|
4. Formatted Input - scanf
|
|
The function scanf is the input analog of printf. |
|
int scanf(char *format, ...); |
– scanf reads characters from standard input, interpreting them according to format specification
– Similar to printf , scanf also takes variable number of arguments.
– The format specification is the same as that for printf
– When multiple items are to be read, each item is assumed to be separated by white space.
– It returns the number of items read or EOF.
– Important: scanf ignores white spaces.
– Important: Arguments have to be address of variables (pointers). |
|
Example |
|
|
|
|
|
|