User Program Communication
User Input in C
Used to receive input (int, word, byte, etc.) from the user in the console.
Syntax
scanf("variableSpecifier", variable);
Notes
The variableSpecifier is used to determine the type of variable, similar to the specifier used in printf: %f, %d, % s (see Print). Since we are passing the input into a defined variable, we need to use the variable in order to store the value of the input.
For integers, scanf scans the pointer to the integer inputted. Because of this, you need to store the scanned value in the integer variable's address.
Example
int number;
printf("What's your favourite number?"); //prompt
scanf( "%d", &number);