+ 1
What is the role of scanf? How it can be used?
2 Answers
+ 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.