#include #include #include #include #define SIZE_LINE 1000+1 bool isAllLower(const char * str); int countLowerWord(const char * str); int main(void) { FILE * file = fopen("parole.txt", "rt"); if (file != NULL) { char str[SIZE_LINE]; int countWord = 0; while (fgets(str, sizeof(str), file)) { countWord = countWord + countLowerWord(str); } printf("Total all-lowercase words: %d\n", countWord); fclose(file); } else { perror("Error (source)"); } return 0; } bool isAllLower(const char * str) { int countAplha = 0; if (strlen(str) == 0) { return false; } for (int i = 0; str[i] != '\0'; i++) { if (isalpha(str[i])) { countAplha++; if (isupper(str[i])) { return false; } } } return true; } int countLowerWord(const char * str) { char buffer[SIZE_LINE]; int countWord = 0; strcpy(buffer, str); for (char * pc = buffer; (pc = strtok(pc, " \n")) != NULL; pc = NULL) { if (isAllLower(pc)) { countWord++; } } return countWord; }