+ 1

What is the role of scanf? How it can be used?

27th Mar 2019, 7:25 PM
Rohan Agarwal
Rohan Agarwal - avatar
2 Answers
+ 13
‱ scanf() is the function for inputting values to a data structure: scanf("%c %d %f", &ch, &i, &x);  NOTE: & before variables.
27th Mar 2019, 8:03 PM
Danijel Ivanović
Danijel Ivanović - avatar
+ 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.
27th Mar 2019, 7:29 PM
Scooby
Scooby - avatar