I need some help with this code is is suppose to open a file "jojo" and find out how many words are in it. then out print that however i seem to be importing the file wrong can someone help me fix that?
#include <stdio.h>
int main(void)
{
FILE *fp;
int c;
char b[1000];
int n=0;
fp = fopen("jojo.txt", "r"); // error check this!
// this while-statement assigns into c, and then checks against EOF:
while((c = fgetc(fp)) != EOF)
{
if (c == ' ')
{
n++;
}
}
fclose(fp);
printf("This file has %d words", n);
return 0;
}