Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and medical aesthetics - In C language, when int and char are mixed, such as scanf ("%d% c% c"); , why do you want to put a space before %c?
In C language, when int and char are mixed, such as scanf ("%d% c% c"); , why do you want to put a space before %c?
God, some people answer just to look good.

Here's the thing: "%d% c% c" without spaces,&; First, & ampb & amp;; C When you enter "3 empty E and F", the first one is plastic, which will naturally assign the number you entered to the first A, the second one is a space, which will be assigned to B as a character, and the third one will be assigned to C. The program will think that the assignment has been completed and will ignore the "empty F" behind it.

Results a=3, b='', c='e'

You can test it like this.

# include & ltstdio.h & gt

Long trunk line ()

{

Long a;

char b,c;

Scanf("%d%c%c ",& i, & ampb & amp;; c); //enter "3 empty e empty f"

printf("%c\n ",c); //the output variable c is' e'

Returns 0;

}