+ 1
What is the role of scanf? How it can be used?
2 Réponses
+ 13
• scanf() is the function for inputting values to a data structure:
scanf("%c %d %f", &ch, &i, &x);
NOTE: & before variables.
+ 3
The scanf function allows you to accept input from standard in, which for us is generally the keyboard.
scanf("%d", &b);
The program will read in an integer value that the user enters on the keyboard (%d is for integers, as is printf, so b must be declared as an int) and place that value into b.