Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to enter the value of EOF in the terminal

Tags:

c

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?

like image 549
user1593308 Avatar asked Aug 15 '12 11:08

user1593308


People also ask

How do I enter EOF in terminal?

You can simulate an EOF with: Windows: ctrl + Z. Unix: ctrl + D.

How do I type EOF characters?

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.


1 Answers

In Windows, Control+Z is the typical keyboard shortcut to mean "end of file", in Linux and Unix it's typically Control+D.

like image 110
unwind Avatar answered Sep 24 '22 07:09

unwind