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?
- Check if input is integer type in C
- Reaching EOF with fgets
- The difference between n++ and ++n at the end of a while loop? (ANSI C)
- Working on code to calculate cosine with factorial sum
- warning: implicit declaration of function
- Two questions about basic C programs
- What exactly is the difference between “pass by reference” in C and in C++?
- What does “collect2: error: ld returned 1 exit status” mean?
- How to convert an int to string in C?
- Floating point exception (core dumped)
- what is the difference between uint16_t and unsigned short int incase of 64 bit processor?
- Correct format specifier for double in printf
- How to convert a string to integer in C?
- What is the behavior of integer division?
- Why use conio.h?
- Awesomium sdk download
- Why does the terminal show “^[[A” “^[[B” “^[[C” “^[[D” when pressing the arrow keys in Ubuntu?
- Write to .txt file?
- Reading from file using read() function
- What is the difference between ++i and i++?
- warning: assignment makes integer from pointer without a cast
- munmap_chunk(): invalid pointer
- printf() formatting for hexadecimal
- The importance of c enumeration (typedef enum) [duplicate]
- What does #pragma once mean in C? [duplicate]
- Connect: Socket operation on non-socket
- Printing long int value in C
- Undefined reference to pow( ) in C, despite including math.h [duplicate]
- Undefined reference to pow( ) in C, despite including math.h [duplicate]
- C programming, error: called object is not a function or function pointer
- How to convert an int to string in C?
- Process finished with exit code 11 | Error during malloc [duplicate]
- How does wait(NULL) exactly work?
- How to replicate vector in c?
- Try catch statements in C
- How do I create an array of strings in C?
- How to check if a string is a number?
- C compile error: “Variable-sized object may not be initialized”
- What does WEXITSTATUS(status) return?
- Difference between a Structure and a Union
- Xcode – Warning: Implicit declaration of function is invalid in C99
- Error: control may reach end of non-void function in C
- The difference between stdout and STDOUT_FILENO
- C language: float % float why expression must have integral type
- Reading \r (carriage return) vs \n (newline) from console with getc?
- Invalid pointer error on invoking free() after malloc in C
- In C, how should I read a text file and print all strings
- What does “Size in TCHARs” means?
- Python ? (conditional/ternary) operator for assignments
- What’s the difference between a file descriptor and file pointer?
- return makes integer from pointer without a cast [-Wint-conversion] return candidate
- Math constant PI value in C
- Cygwin – Makefile-error: recipe for target `main.o’ failed
- Why am I getting “undefined reference to sqrt” error even though I include math.h header?
- Why am I getting “undefined reference to sqrt” error even though I include math.h header?
- How can I use an array of function pointers?
- Expected declaration specifier error in function
- When and why to use malloc?
- Multiple definition of … linker error
- Does sizeof return the number of bytes or the number of octets of a type in C?
- C compile error: Id returned 1 exit status
- How do I concatenate const/literal strings in C?
- Efficient way to find task_struct by pid
- Why am I getting this memory access error ‘double free or corruption’?
- Passing an array by reference in C?
- size of struct in C
- Warning: return from incompatible pointer type in C
- How to generate a random number between 0 and 1?
- How can one print a size_t variable portably using the printf family?
- How to make sense of modulo in c
- Memory Clobbering Error
- “No such file or directory” error in CodeBlocks
- Iterate through a C array
- Uninitialized value was created by a heap allocation
- Makefile:1: *** missing separator. Stop
- double free or corruption (!prev) error in c program
- xorl %eax – Instruction set architecture in IA-32
- What does this GCC error “… relocation truncated to fit…” mean?
- Using floats with sprintf() in embedded C
- Printf width specifier to maintain precision of floating-point value
- Two or more data types in declaration specifiers error
- ‘sprintf’: double precision in C
- C printing bits
- How do I find the time complexity (Big O) of while loop?
- Why do we use NULL in strtok()?
- PTHREAD_MUTEX_INITIALIZER vs pthread_mutex_init ( &mutex, param)
- How to concatenate string and int in C?
- execvp: bad address error
- How detect malloc failure?
- A Simple, 2d cross-platform graphics library for c or c++?
- Removing last character in C
- error: ISO C forbids nested functions – What’s wrong?
- Dereference void pointer
- Use of flag in c?
- Carriage return in C?
- fgetc(stdin) in a loop is producing strange behaviour
- Difference between “while” loop and “do while” loop
- Swapping 2 Bytes of Integer
- GDB no such file or directory