Home > Back-end >  A novice C language problem
A novice C language problem

Time:11-16

Feel to play out no problem, but I just can not output the c value, for passing bosses answer

CodePudding user response:

The input stream;
The scanf function reads cache flow kept covered with a carriage return variable symbol inside, need to clear the input stream buffer;
Can adopt the method of add print, can see the problem;

CodePudding user response:

If (b=0 & amp; & Symbol=='/'); This sentence should be changed to the if (b==0 & amp; & Symbol=='/');

CodePudding user response:

Symbol uninitialized variables, which is a random value, so there will be problems, directly determine the undefined, suggested that the original poster to the scanf symbol in the loop, and then put this statement at the end of the while;
Notice at the same time, the last input '\ n' is still in the input buffer, to consider getchar () to absorb,
  • Related