How do I check if input is just an empty line??
Code:input = fopen("test.dat", "r"); while (!feof(input)){ if(fscanf(input, .................... }
How do I check if input is just an empty line??
Code:input = fopen("test.dat", "r"); while (!feof(input)){ if(fscanf(input, .................... }
The same way you check to see if it's an empty line in notepad. Look at it and see what's there.
Quzah.
Hope is the first step on the road to disappointment.
You should be able to figure out what it does, it just makes sure that there are two lines because if there is a character preceding the newline character than that line is not empty.Code:#include <stdio.h> int main( void ) { char buffer[20] = { 0 }; int a, charsread = 0; input = fopen("test.dat", "r"); while (!feof(input)) { charsread = fscanf(input, "%20s", buffer ); for( a = 0; a < charsread; a++ ) //a++ is preferred because it looks better ;) { if( buffer[a] == '\n' && buffer[a + 1] == '\n' ) { printf("Empty Line found\n"); } } } fclose(input); return 0; }
Last edited by DeadPlanet; 05-06-2009 at 06:00 AM.
It depends on your definition of blank. Like I said, look at it and decide if it's blank.
Quzah.
Hope is the first step on the road to disappointment.