Tests for palindromes in C and C++ A question I've been asked on interactive phone screens is to code a test to determine whether a string is
a palindrome or not. I am providing two examples here: one in C and one in C++. They both work and they both compile
without errors or warnings. I believe my C example is good, with the possible exception of variable names
(some of you may not like the register char* declarations, but they are valid in C).

My goal was an \$O(n)\$ solution with out reversing the string.

My question is about the C++ version, and I miss using iterators. Is there a way to make this more C++ like?

I can think in C; I can't necessarily think in C++.

Palindrome checker in C  

#include &lt;stdio.h&gt;
#include &lt;string.h&gt;
#include &lt;stdbool.h&gt;

bool palindromeChecker(char *possiblePalindrome)
{
    bool isPalindrome = true;
    size_t length = strlen(possiblePalindrome);

    if (length &lt; 3)
    {
        isPalindrome = false;
    }
    else
    {
        register char *leftSide = possiblePalindrome;
        register char *rightSide = &amp;possiblePalindrome[length-1];

        while ((leftSide &lt; rightSide) &amp;&amp; isPalindrome)
        {
            if (*leftSide != *rightSide)
            {
                isPalindrome = false;
            }
            leftSide++;
            --rightSide;
        }
    }

    return isPalindrome;
}

int main(int argc, const char * argv[]) {
    char testString[BUFSIZ];
    bool iSPalendrome;

    printf("Enter a test string to be checked for if it is a palindrome\n");
    scanf("%s", testString);
    iSPalendrome = palindromeChecker(testString);
    printf("The test string %s is %s a palindrome\n", testString, (iSPalendrome? "" : "Not"));

}


Palindrome checker in C++  

#include &lt;iostream&gt;
#include &lt;string&gt;

bool IsPalindrome(std::string PossiblePalindrome)
{
    bool Palidrime = true;

    if (PossiblePalindrome.size() &lt; 3)
    {
        Palidrime = false;
    }
    else
    {
        std::string::iterator leftSide = PossiblePalindrome.begin();
        std::string::iterator rightSide = PossiblePalindrome.end();
        rightSide--; // end is past the end of the possible palindrome so decrement to point to a character.

        while ((leftSide &lt; rightSide) &amp;&amp; Palidrime)
        {
            if (*leftSide != *rightSide)
            {
                Palidrime = false;
            }
            leftSide++;
            rightSide--;
        }
    }

    return Palidrime;
}

int main(int argc, const char * argv[]) {
    // insert code here...
    std::string PossiblePalindrome;
    std::cout &lt;&lt; "Enter a string to test to see if it is a palindrome.\n";
    std::cin &gt;&gt; PossiblePalindrome;

    std::cout &lt;&lt; "The string " &lt;&lt; PossiblePalindrome;
    if (IsPalindrome(PossiblePalindrome))
    {
        std::cout &lt;&lt; " is";
    }
    else
    {
        std::cout &lt;&lt; " is not";
    }
    std::cout &lt;&lt; " a palindrome" &lt;&lt; std::endl;
}
A special case length &lt; 3 seems like a bug. A string aa is a palindrome, and one could successfully argue that a single-letter string is also a palindrome.
A boolean isPalindrome is redundant, and forces the code to test the effectively same condition twice. An early return is perfectly fine here.
A traditional idiomatic (and arguably more performant) way to iterate forward is *first++. Similarly, an idiom for iterating backwards is *--last (that also avoids subtracting 1 beforehand):

    last = possiblePalindrome.end();
    while (first &lt; last) {
        if (*first++ != *--last) {
            return false;
        }
    }
    return true;

The naming is very inconsistent. I don't see the reason to spell palindrome in 3 different ways. A capitalization in iSPalendrome is also strange.