>while(!eof(fp))
I think you meant while ( !feof ( fp ) ). Even then it's incorrect, you can search the boards for further details, it's been covered quite a bit. A better way is to declare ch as an int and do this:

Code:

while( ( ch = fgetc ( fp ) ) != EOF )
{
if ( ch == '\n' )
count++;
}

You also might consider adding code to check if the file contains data and emptying it before doing anything else. You'll notice that if you run the program several times in succession the number of files keeps increasing because you don't clear the file.

I also cut the time this program takes to run in half by declaring a buffer and using fgets instead of fgetc.

>while(!eof(fp))
I think you meant while ( !feof ( fp ) ). Even then it's incorrect, you can search the boards for further details, it's been covered quite a bit. A better way is to declare ch as an int and do this: