|
When the scanf () function accepts data, it usually uses the enter key as the input to end a data (space bar, tab key is also OK), you will understand by giving an example
#include <stdio.h>
int main ()
{
int n1, n2;
scanf ("% d",&n1);
n2 = getchar ();
printf ("n1 =% d, n2 =% d", n1, n2);
}
When entering, please enter 12 and Enter, where n2 = 10, 10 is the decimal number of '\n'
If you enter 12 and space and Enter when entering, where n2 = 32. 32 is the decimal number of the space bar
The examples in the book are handled according to the general situation |
|