#include #include int main(){ FILE *fp; char buf = ' '; int word_count=0, flag=0; if((fp = fopen("text.txt", "r")) == NULL) printf("Error to open file"); while(fread(&buf, sizeof(char), 1, fp)){ if(buf != ' ') flag = 1; else if(flag){ flag=0; word_count++; } } if(flag) word_count++; fclose(fp); printf("Count of words: %d\n", word_count); return 0; }