Hey guys I've been all sorts of methods on trying to find particular strings from a file that has thousands of strings. Im searching for palindromes, I have a code that actual determines if a word is a palindrome but the process of finding it im stuck on, I assume its a loop or a getline. Any help, tips or hints would highly be appreciated. Heres my function for the palindrome.
// returns true if word is a palindrome, false if not.
bool isPalindrome(const char word)
bool is_palindrome = true;
// assume it's a palindrome until we see a mis-match
int len = strlen(word);
int index_of_last = len - 1;
/* Only first half of array needs to be checked
(since we're comparing it to the second half).
Here we WANT integer division -> integer result:
works for odd and even number of characters.
If we find a mis-match, this is not a palindrome and we should stop looping.
for (int i=0; i<len/2 && is_palindrome; i++)
if (word[i] != word[index_of_last - i])
is_palindrome = false; // not a palindrome