Home > Back-end >  C the scanf
C the scanf

Time:09-16

According to the format requirements input and output data,
#include
The main ()
{int a, b;
Float x, y;
Char c1 and c2.
The scanf (" a=% d, b=% d ", & amp; A, & amp; B);
The scanf (" % f, % e ", & amp; X, & amp; Y);
The scanf (" % % % c c c ", & amp; C1, & amp; C1, & amp; C2); Line 8 *//*
Printf (" a=% d, b=% d, x=% f, y=% f, % c1=c, c2=% c \ n ", a, b, x, y, c1, c2);
}
Program in line 8, why variable c1 to enter twice?

CodePudding user response:

Don't have to enter the second, modify it is ok

CodePudding user response:

You are the scanf read 2 times

CodePudding user response:

Delete a line

CodePudding user response:

Because '\ n' coincided with the first % c match

CodePudding user response:

The scanf (" a=% d, b=% d ", & amp; A, & amp; B); Left a '\ n'
Due to the scanf (" % f, % e ", & amp; X, & amp; Y); Read only the floating-point ignored '\ n', at the same time the statement remaining a '\ n' read
The scanf (" % % % c c c ", & amp; C1, & amp; C1, & amp; C2); Read the '\ n' assigned to c1, next should input the value of c1 and c2, so read this statement is still two characters, assigned to c1 and c2

CodePudding user response:

You cow force, his hard on yourself
  • Related