counting whitespace characters
Hey, I have spent about an hour trying to figure out what is wrong with this code. I have tried every variation of it that I can think of. I'm trying to count the whitespaces in a text file. This function is, of course, only part of the program. When the program runs, "count" gets printed as 0. Everything I've tried ends up with "count" being zero. I can't figure it out. Thanks for the help in advance.
Here's the code:
Code:
void countspace( FILE* inFile)
{
char ch;
int count = 0;
while (fscanf (inFile, "%c", &ch) != EOF)
if (isspace(ch))
count++;
printf("\nThere are %d white space characters.", count);
return;
}