It’s because scanf
will leave a '\n'
(endline) symbol in the input buffer. This symbol will be consumed by getchar
at the first iteration of this while(1)
loop.
More Related Contents:
- Lex program input doesn't terminate [closed]
- which is faster assigning a number to the variable or changing the value of that variable either by adding or subtracting some number?
- Storing value of unsigned int variable in char array in C [closed]
- C program goes into infinite loop with scanf [duplicate]
- Validating input with isdigit for a factorial program
- Simple C scanf does not work? [duplicate]
- Difference between char *pp and (char*) p?
- Pointers in C: when to use the ampersand and the asterisk?
- printf format specifiers for uint32_t and size_t
- “error: assignment to expression with array type error” when I assign a struct field (C)
- Mixing C functions in an Objective-C class
- Why do I need to use type** to point to type*?
- Need of Pointer to pointer
- Bitfield manipulation in C
- How do we test the return values from the scanf() function?
- What happens when a variable goes out of scope?
- Where to find stdio.h functions implementations?
- I do not understand how execlp() works in Linux
- Understanding the collapse clause in openmp
- Delete a Line from a file in C Language
- Setting std=c99 flag in GCC
- Why are global variables bad, in a single threaded, non-os, embedded application
- Determine if a C string is a valid int in C
- Store data in array from input [duplicate]
- Array of size 0 at the end of struct [duplicate]
- Avoiding the main (entry point) in a C program
- Where are syscalls located in glibc source
- Dynamic array allocation on stack in C
- how to use yy_scan_string in lex
- How to implement Bitcount using only Bitwise operators?