问题
i was studying EOF character in c and came across a program :
#include <stdio.h>
main()
{
int c= 0;
while((c = getchar())!=EOF)
putchar(c);
}
its all good it is giving proper o/p but how do i come out of the loop by entering a EOF character which i entered and it did nothing.
回答1:
To stimulate EOF
in stdin
,
- If you are on windows or DOS press CTRL+Z
- Or if you are running linux or some other OS, press CTRL+D
回答2:
I dont think there is an EOF character,and CTRL+Z and CTRL+D are used to inform the OS for termination. Follow these links it has the answers Representing EOF in C code? End of File (EOF) in C
来源:https://stackoverflow.com/questions/28380039/how-do-i-enter-an-eof-character-in-this-program