1234
void main(){ char s[MX], word[MX]; int i; File *fin = fopen(F,"r");
1234567891011121314151617181920212223242526
#include <stdio.h> #include <string.h> #define F "wisdom.txt" #define MX 500 int main() { FILE* fin = fopen(F, "r"); if (fin == NULL) { printf("Warning: No %s file found. Program is now terminating.", F); return 1; } for (char s[MX]; fgets(s, MX, fin) != NULL; ) { int i = 0; printf("\n%s", s); for (char *word = strtok(s, " "); word != NULL; ++i, word = strtok(NULL, " ")); printf("Total words: %d\n---------------\n", i); } return 0; }