OF
is only an integer constant. On most systems it is -1
. !-1
is false
and while(false)
won’t do anything.
What you want is to check the return values of scanf
. scanf
returns the number of successfully read items and eventually EOF
.
Related Posts:
- How to use execvp()
- How does strtok() split the string into tokens in C?
- Using boolean values in C
- typedef struct vs struct definitions [duplicate]
- How to print in C
- Why should we typedef a struct so often in C?
- How to convert an int to string in C?
- What does the question mark character (‘?’) mean?
- Stack smashing detected
- Stack smashing detected
- Why am I getting “void value not ignored as it ought to be”?
- What is the behavior of integer division?
- Difference between malloc and calloc?
- How do function pointers in C work?
- What causes the Broken Pipe Error?
- Strings and character with printf
- Why does the terminal show “^[[A” “^[[B” “^[[C” “^[[D” when pressing the arrow keys in Ubuntu?
- “Expected expression before ‘ { ‘ token”
- C pointers and arrays: [Warning] assignment makes pointer from integer without a cast
- Why use bzero over memset?
- Reading from file using read() function
- What does “collect2: error: ld returned 1 exit status” mean?
- warning: assignment makes integer from pointer without a cast
- printf() formatting for hexadecimal
- What does #pragma once mean in C? [duplicate]
- How do I properly compare strings in C?
- How do we check if a pointer is NULL pointer?
- what is the meaning of == sign?
- How do I calculate MB/s & MiB/s?
- Printing long int value in C
- Cannot assign requested address – possible causes?
- C programming, error: called object is not a function or function pointer
- warning: implicit declaration of function
- Returning string from C function
- How to replicate vector in c?
- Why do I get clang: error: linker command failed with exit code 1?
- Why am I getting “void value not ignored as it ought to be”?
- Difference between scanf() and fgets()
- How to check if a string is a number?
- What does WEXITSTATUS(status) return?
- Get the current time in C
- Does connect() block for TCP socket?
- Reading \r (carriage return) vs \n (newline) from console with getc?
- #31 expression must have integral type
- Invalid pointer error on invoking free() after malloc in C
- What’s the equivalent of new/delete of C++ in C?
- In C, how should I read a text file and print all strings
- C read file line by line
- Using Dynamic Memory allocation for arrays
- Python ? (conditional/ternary) operator for assignments
- C read file line by line
- Copying a part of a string (substring) in C
- return makes integer from pointer without a cast [-Wint-conversion] return candidate
- error: indirection requires pointer operand (‘int’ invalid)
- Incompatible implicit declaration of built-in function ‘malloc’
- What does “%.*s” mean in printf?
- error: indirection requires pointer operand (‘int’ invalid)
- How can I use an array of function pointers?
- Display value found at given address gdb
- What is a bus error? Is it different from a segmentation fault?
- What’s wrong with my code? What is argv[1]?
- Expected declaration specifier error in function
- Valgrind: Invalid read of size 1
- How to clear all the elements of array in C?
- 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
- Reversing a string in C
- Efficient way to find task_struct by pid
- How to remove the character at a given index from a string in C?
- size of struct in C
- Expected declaration specifier error in function
- Encrypt with private key and decrypt with public key
- Why I do get “Cannot find bound of current function” when I overwrite the ret address of a vulnerable program?
- How to use timer in C?
- C char* to int conversion
- Writing binary number system in C code
- How can one print a size_t variable portably using the printf family?
- Check if input is integer type in C
- Return a `struct` from a function in C
- char pointers: invalid conversion from ‘char*’ to ‘char’?
- What is the difference between char array and char pointer in C?
- Makefile:1: *** missing separator. Stop
- double free or corruption (!prev) error in c program
- What happens during a “relocation has invalid symbol index” error?
- What does this GCC error “… relocation truncated to fit…” mean?
- 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 to convert an integer to a character array using C
- Why do we use NULL in strtok()?
- How to convert string to float?
- switch case: error: case label does not reduce to an integer constant
- ld.exe: cannot open output file … : Permission denied
- previous declaration of ‘function’ was here in C [duplicate]
- segmentation fault using scanf
- Segmentation fault- strcat
- fgetc(stdin) in a loop is producing strange behaviour
- segmentation fault with strcpy [duplicate]
- Compiler warning – suggest parentheses around assignment used as truth value