The scanf() function can read in any value specified by a conversion character.
The following scanf() reads an Integer.
#include <stdio.h> int main() //from w ww. ja va2s.c om { int f; printf("What is your favorite number: "); scanf("%d",&f); printf("%d is my favorite number, too!\n",f); return(0); }
The %d conversion character is used, just like printf().
That character directs scanf() to look for an int value for variable f.
The ampersand (&) in the scanf() function is a C memory address operator.