So I'm trying to check part of a string against another part of the same string, but it doesn't seem to be a use of brackets for the location in the string like I was led to believe.
I just need some help with the location in the string.
1 2 3 4 5 6 7 8 9 10
bool PT(int& loop, int length, string ppd)
{
int endDIS = length - loop;
if (ppd[endDIS] == ppd[loop])
{
loop++;
return PT(loop, length, ppd);
}
}
I want ppd[endDIS] to be a single character, just like ppd[loop], but when I trace the program through, even when using AA, the function always returns false, and never goes into the if statement shown
It looks like you're trying to test if the string is a palindrome. In the above line, when loop is 0, endDIS will be length. So, you'll be comparing the first letter of the string to the nul character which ends it.