How to enter the value of EOF in the terminal

Solution 1:

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

Solution 2:

  1. EOF is wrapped in a macro for a reason - you never need to know the value.
  2. From the command-line, when you are running your program you can send EOF to the program with Ctrl-D (Unix) or CTRL-Z (Microsoft).
  3. To determine what the value of EOF is on your platform you can always just print it:

    printf ("%i\n", EOF);
    

Solution 3:

You can simulate an EOF with:

  • Windows: ctrl+Z
  • Unix: ctrl+D

Solution 4:

It's not mentioned in any of the other answers so far, but you may need to press the right key combo (^D or ^Z) 2 or 3 times in order to actually signal EOF; see here for explanation.