I have a C program.
int main () { if (getchar()!=EOF) puts("Got a character"); else puts("EOF"); }
What should I type into the stdin on the terminal to produce an EOF?
You can simulate an EOF with: Windows: ctrl + Z. Unix: ctrl + D.
The EOF in C/Linux is control^d on your keyboard; that is, you hold down the control key and hit d. The ascii value for EOF (CTRL-D) is 0x05 as shown in this ascii table . Typically a text file will have text and a bunch of whitespaces (e.g., blanks, tabs, spaces, newline characters) and terminate with an EOF.
In Windows, Control+Z is the typical keyboard shortcut to mean "end of file", in Linux and Unix it's typically Control+D.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With