Well having formatted it to resolve the crap indentation (if you did this, you might actually see something), we see
Code:
#include <stdio.h>
#include <stdlib.h>
int main()
{
FILE *inFile;
char filename[64];
printf("\nEnter a file name: ");
gets(filename);
fflush(stdin);
getchar();
inFile = fopen(filename, "r");
if (inFile == NULL) {
printf("\nThe File %s was not successfully opened.", filename);
printf("\nPlease check that the file currently exists. \n");
return (1);
}
int countword = 0;
int countchar = 0;
int linecount = 0;
int count = 0;
char c;
c = getc(inFile);
while (c != EOF);
{
countchar++;
if (c == '\n')
linecount++;
if (c == ' ')
countword++;
c = getc(inFile);
}
fclose(inFile);
if (countchar != 0);
{
printf("Number of characters = %d, number of lines = %d, Number of words%d\n", countchar,
linecount, countword);
}
fflush(stdin);
getchar();
} //!! yes, this was missing
Now, compiling the code with a real compiler (and not TurbidCrap so beloved by useless teachers)
$ gcc -W -Wall foo.c
foo.c: In function ‘main’:
foo.c:38: warning: suggest braces around empty body in an ‘if’ statement
foo.c:24: warning: unused variable ‘count’
/tmp/ccPYkjcg.o: In function `main':
foo.c:(.text+0x32): warning: the `gets' function is dangerous and should not be used.
Now, look REALLY carefully at that "empty body" warning.
Because your while loop suffers from the same problem.
I should also add that since mixing declarations and statements is a NEW C feature, you must be compiling this code with a C++ compiler. This is just another example of your so-called teacher teaching the compiler, and not the language. Listen, when you move to another compiler (anywhere outside of college for example), you're in for a lot of surprises.