I'm making this Palindrome recursion program, and capitals are changed to lower case, and all blanks and punctuation must be ingnored. I've tested all my other functions and they work, except for the one that removes the blanks and punctuation.
Code:
void Cleanup_String(char *stringptr1)
{
char *stringptr2 = stringptr1;
char *debugptr = stringptr1;
for(; *stringptr1 != '\0'; stringptr1++)
{
*stringptr1 = tolower(*stringptr1);
}//checked
for(; stringptr2 != '\0'; stringptr2++)
{
if ( !(isalpha (*stringptr2) ) )
{
for( char * temptr = stringptr2; temptr != '\0'; temptr++)
{
*temptr = *(temptr+1);
}
}
} //Error in this whole loop
cout << debugptr << endl;
cout << "Finished loop." << endl;
return;
}
The first for loop makes everything lowercase, but the 2nd for loop group is supposed to clear out the spaces and puncuation by moving the string down an index to overwrite the space or puncuation, but it isn't working and I was wondering if I'm not using isalpha correctly. I would think the syntax for the whole looping proccess is correct.. Also, for some reason, when I run the program, it enters that function, but never quits it, I just get the "Enter any key to end this program."
Thanks.