#include #include #include #include int isPalindrome(char *str); int main(void) { FILE *file = fopen("palindrome.txt", "r"); char *token, line[512]; if (file == NULL) { perror("Error opening file"); return EXIT_FAILURE; } while (fgets(line, sizeof(line), file)) { token = strtok(line, ","); while (token != NULL) { if (isPalindrome(token)) { printf("palindrome found: %s\n", token); } token = strtok(NULL, ","); } } fclose(file); return EXIT_SUCCESS; } int isPalindrome(char *str) { int i, length = strlen(str); for (i = 0; i < length / 2; i++) { if (tolower(str[i]) != tolower(str[length - 1 - i])) { return 0; } } return 1; }