Home > Back-end >  When typing the command at the end of the while statement is always flash back, try in various place
When typing the command at the end of the while statement is always flash back, try in various place

Time:11-22

# include & lt; stdio.h>
Int main (void)
{
Long num.
Long sum=0 l;
Int the status;
Printf (" both Please enter an integer to be summed ");
Printf (" (q to quit) : ");
Status=the scanf (" % ld ", & amp; Num);
While (status==1)
{
Sum=sum + num;
Printf (" do enter next integer (q to quit) : ");
Status=the scanf (" % ld ", & amp; Num);
}
Printf (" Those integers sum to % ld. \ n ", sum);
getchar();
return 1;
}

CodePudding user response:

Append a more getchar
Or getchar into the system (" pause ");

CodePudding user response:

Flash back because of the building after the last input and a newline character in the input buffer, thus getchar (); Just received '\ n', so they returned, namely the flash back,
Can consider according to the above method, add a getchar (); Or it in the system (" pause "); Try ~

CodePudding user response:

Problem has been solved, we'll need to add two getchar ()
  • Related