Palindrome prog, removing whitespace

I have an assignment where i have to make a palindrome program. As you can see i have already done the basic palindrome prog, however i am now stuck since the program goes into a infinite loop whenever a word with whitespaces is added.

I have also tried searching for methods online however they do not seem to work for me...

The for loop for( int i = 0 ; p > i ; ++i, --p ) is identical to the one that you wrote;
the variable names i and p in your original were deliberately retained, and have the same meaning.

The difference is in the two while loops.

while( p>i && ( isspace(cstr[i]) || ispunct(cstr[i]) ) ) ++i ;
If the next character (the one at position i) is one to be skipped , increment i till we hit a character that is not a white space or punctuation.