Home > Back-end >  Consult about Ctrl z and EOF
Consult about Ctrl z and EOF

Time:01-20

# include

Int main (int arg c, char * const argv)
{
int a;
Int b;
While (the scanf (" % d ", & amp; A)! EOF)={
B++;
Printf (" % d \ n ", b);
}
Printf (" % d ", b);
return 0;
}
Program is running above input ^ z (Ctrl z) end of the cycle 0
But at the same time enter 123 ^ z (Ctrl z) cycle cannot end is why? The small white consult

CodePudding user response:

Run no problem:
 # include 


//the above program run time input ^ z (Ctrl z) end of the cycle 0
//but at the same time enter 123 ^ z (Ctrl z) cycle cannot end is why?


Int main (int arg c, char * const argv)
{
int a;
Int b=0;
While (the scanf (" % d ", & amp; A)! EOF)={
B++;
Printf (" % d \ n ", b);
}
Printf (" % d ", b);

return 0;
}

CodePudding user response:

reference 1st floor QZJHJXJ response:
run no problem:
 # include 


//the above program run time input ^ z (Ctrl z) end of the cycle 0
//but at the same time enter 123 ^ z (Ctrl z) cycle cannot end is why?


Int main (int arg c, char * const argv)
{
int a;
Int b=0;
While (the scanf (" % d ", & amp; A)! EOF)={
B++;
Printf (" % d \ n ", b);
}
Printf (" % d ", b);

return 0;
}


Strange, I run on Dev - c + + and VScode are infinite loop
  • Related