fscanf
– “On success, the function returns the number of items successfully read. This count can match the expected number of readings or be less -even zero- in the case of a matching failure. In the case of an input failure before any data could be successfully read, EOF is returned.”
So, instead of doing nothing with the return value like you are right now, you can check to see if it is == EOF
.
You should check for EOF when you call fscanf
, not check the array slot for EOF.
Related Posts:
- Scanf/Printf double variable C
- How to printf “unsigned long” in C?
- How I can print to stderr in C?
- Difference between scanf() and fgets()
- Going through a text file line by line in C
- Reading a string with scanf
- Going through a text file line by line in C
- How to do scanf for single char in C
- Scanning Multiple inputs from one line using scanf
- How do you allow spaces to be entered using scanf?
- Difference between fgets and fscanf?
- how use EOF stdin in C
- How do you read scanf until EOF in C?
- Reading in double values with scanf in c
- Simple C scanf does not work? [duplicate]
- How to read from input until newline is found using scanf()?
- Reading float using scanf in c
- Reading float using scanf in c
- The difference between n++ and ++n at the end of a while loop? (ANSI C)
- How many spaces for tab character(\t)?
- Working on code to calculate cosine with factorial sum
- warning: implicit declaration of function
- What is the effect of extern “C” in C++?
- What exactly is the difference between “pass by reference” in C and in C++?
- What does “collect2: error: ld returned 1 exit status” mean?
- What is the behavior of integer division?
- max value of integer
- Convert an int to ASCII character
- Awesomium sdk download
- Bad File Descriptor with Linux Socket write() Bad File Descriptor C
- What is the difference between char s[] and char *s?
- Error “initializer element is not constant” when trying to initialize variable with const
- What is the difference between read and pread in unix?
- What does “control reaches end of non-void function” mean?
- connect Error: “No route to host”
- C error: undefined reference to function, but it IS defined
- What is the printf format specifier for bool?
- warning: implicit declaration of function
- C dynamically growing array
- Why do I get an assertion failure?
- lvalue required as left operand of assignment
- how to convert negative hexadecimal to decimal
- Why am I getting “undefined reference to sqrt” error even though I inclu de math.h header?
- How to initialize a struct in accordance with C programming language standards
- Expression preceding parentheses?
- Linux equivalent of I_PUSH
- Understanding INADDR_ANY for socket programming
- The Definitive C Book Guide and List[
- When is it a good idea to use strdup (vs malloc / strcpy)
- expression must have integral type
- Why is %c used in C?
- What’s wrong with my code? What is argv[1]?
- What can cause a “Resource temporarily unavailable” on sock send() command
- How to get the current directory in a C program?
- What’s the best way to check if a file exists in C?
- How to solve error: expected identifier or ‘(‘
- C compile : collect2: error: ld returned 1 exit status
- Split string with delimiters in C
- c array – warning: format not a string literal
- How to pause in C?
- (.text+0x20): undefined reference to `main’ and undefined reference to function
- Why am I getting this error: “data definition has no type or storage class”?
- I’m getting “Invalid Initializer”, what am I doing wrong?
- How to prevent multiple definitions in C?
- How can you print multiple variables inside a string using printf?
- Multi-character constant warnings
- warning: passing argument ’from incompatible pointer type [enabled by default]’
- Return a `struct` from a function in C
- C dynamically growing array
- Why should we check WIFEXITED after wait in order to kill child processes in Linux system call?
- How to convert const char* to char* in C?
- How to parse in C
- error: unknown type name ‘bool’
- Optional arguments in C function
- Which of sprintf/snprintf is more secure?
- Where is the
header file on Linux? Why can’t I find ? - Trim a string in C [duplicate]
- Casting a pointer to an int
- How to repeat a char using printf?
- C Unknown type name ‘my_structure’
- Source file not compiled Dev C++
- 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?
- How to display hexadecimal numbers in C?
- A Simple, 2d cross-platform graphics library for c or c++?
- Removing last character in C
- Difference between char *argv[] and char **argv for the second argument to main()
- How do you format an unsigned long long int using printf?
- error : storage class specified for parameter
- Dereference void pointer
- write() to stdout and printf output not interleaved?
- Difference between “while” loop and “do while” loop
- Swapping 2 Bytes of Integer
- GDB no such file or directory
- Level vs Edge Trigger Network Event Mechanisms
- How to convert integers to characters in C?
- variably modified array at file scope in C
- How to use random() in C [duplicate]