On Linux systems and OS X, the character to input to cause an EOF is Ctrl–D. For Windows, it’s Ctrl–Z.
Depending on the operating system, this character will only work if it’s the first character on a line, i.e. the first character after an Enter. Since console input is often line-oriented, the system may also not recognize the EOF character until after you’ve followed it up with an Enter.
And yes, if that character is recognized as an EOF, then your program will never see the actual character. Instead, a C program will get a -1
from getchar()
.
Related Posts:
- What is EOF in the C programming language?
- How to use redirection in C for file input
- Why use conio.h?
- How to read groups of integers from a file, line by line in C++
- Reading in from System.in – Java
- Check if input is integer type in C
- How to use EOF to run through a text file in C?
- C++ – pointer being freed was not allocated error
- How do you read scanf until EOF in C?
- Representing EOF in C code?
- Reaching EOF with fgets
- Frontend Category Checkbox
- Input with pattern not working
- warning: implicit declaration of function
- What is the difference between ++i and i++?
- Stack smashing detected
- Why am I getting “void value not ignored as it ought to be”?
- Pointer Arithmetic
- Openssl : error “self signed certificate in certificate chain”
- How do I create an array of strings in C?
- How do function pointers in C work?
- segmentation fault : 11
- “error: assignment to expression with array type error” when I assign a struct field (C)
- munmap_chunk(): invalid pointer
- What is the LD_PRELOAD trick?
- What is the argument for printf that formats a long?
- Using %s in C correctly – very basic level
- How do you make an array of structs in C?
- Fastest JSON reader/writer for C++
- What is the difference between const int*, const int * const, and int const *?
- How to create my own header file in c++?
- Why am I getting InputMismatchException?
- Returning string from C function
- Char Comparison in C
- Getting Keyboard Input
- Fatal error: iostream: No such file or directory in compiling C program using GCC
- C – The %x format specifier
- What does it mean to write to stdout in C?
- what is the unsigned datatype?
- Examples of good gotos in C or C++
- Reading a string with scanf
- getopt_long() — proper way to use it?
- C read file line by line
- C read file line by line
- Copying a part of a string (substring) in C
- Incompatible implicit declaration of built-in function ‘malloc’
- expression must have integral type
- Quick Way to Implement Dictionary in C
- gdb: “No symbol table is loaded”
- Need more information about Aborted (core dumped)
- Going through a text file line by line in C
- How to use glOrtho() in OpenGL?
- Reversing a string in C
- When a number is written as 0x00… what does the x mean
- How to remove the character at a given index from a string in C?
- waitpid, wnohang, wuntraced. How do I use these
- Convert C program into assembly code
- execv vs execvp, why just one of them require the exact file’s path?
- difference between
and - Writing binary number system in C code
- Returning an array using C
- Debug vs Release in CMake
- What are 0x01 and 0x80 representative of in C bitwise operations?
- Convert char array to string use C
- How to make parent wait for all child processes to finish?
- Use of cudamalloc(). Why the double pointer?
- Read and write to binary files in C?
- Expression must be a pointer to a complete object type using simple pointer arithmetic
- Difference between sizeof(char) and sizeof(char *)
- How to empty a char array?
- Undefined reference to main – collect2: ld returned 1 exit status
- What does ** mean in C?
- Is there a way to have printf() properly print out an array (of floats, say)?
- How do you allow spaces to be entered using scanf?
- Preventing console window from closing on Visual Studio C/C++ Console application
- What is the proper equivalent of “while(true)” in plain C?
- Getting input from the user in Lua
- How do I compile the asm generated by GCC?
- What is the difference between %g and %f in C?
- What is the source of the data for the ProgramFiles, ProgramW6432Dir, ProgramFilesDir (x86), CommonProgramFiles environment variables?
- Structure padding and packing
- Allocating char array using malloc
- Implementation of strtok() function
- C fopen vs open
- switch case: error: case label does not reduce to an integer constant
- warning: incompatible implicit declaration of built-in function ‘printf’ [enabled by default]
- The difference between char * and char[] [duplicate]
- How to clear input buffer in C?
- Multiple inputs on one line
- In C, what exactly happens when you pass a NULL pointer to strcmp()?
- Linker error: “linker input file unused because linking not done”, undefined reference to a function in that file
- Constructor for structs in C
- Implicit function declarations in C
- Convert long long to string in C?
- Compiler warning – suggest parentheses around assignment used as truth value
- Send attachments via wp_mail from temporary folder
- How do I setup nested repeatable option fields?
- Custom Post Type, Saving Multiple Checkboxes
- How to use jQuery(…).material_chip inside WordPress?
- Remove active cursor from form field