So I am trying to write a program that counts the number of words in a text file.
main(void){
int wordcount = 0;
FILE *infile = fopen("Text.txt", "r");
wordcount += word_count(infile);
printf("%d", wordcount);
return 0;
}
int word_count()
{
int wordcount(FILE *infile);
int count;
char it;
while ((it = fgets(infile)!=EOF))
{
if (it =='
')
{
count++
}
}
return count;
}
But when I run it, I got these errors:
infile undeclared identifier
fgets too few aruguments for function call
what am I doing wrong?
See Question&Answers more detail:os