#include int count(const char *filename){ FILE *file = fopen(filename, "r"); if(!file) return 1; int words = 0; int cara_word = 0; //cara pour compter les words int cara = 0; int lines = 0; int c = fgetc(file); while(c != EOF){ cara ++; if(c == '\n') lines ++; if (c != ' ' && c != '\n' && c != '\t' && c != EOF) cara_word ++; else { if (cara_word > 0) words ++; cara_word = 0; } c = fgetc(file); } fclose(file); printf("> characters: %i\n> words: %i\n> lines: %i\n", cara, words, lines); return 0; } /* int main() { return count("example.txt"); // <-- return 0, because example.txt exists // Expected: //> characters: 2030 //> words: 103 //> lines: 5 } */