Hi, I would want to know how yo can know if a sentence is a palindrome using pointers. I have never used pointers in any language before but I know for a fact that are essential in Computer Science. Can any one give a hand?
Assuming the sentence is a C string, use strlen to get the string length.
Then set one char pointer to the start of the string, and one to the end.
Dereference each pointer, and see if the characters match, if they don't you don't have a palindrome.
If they do match, increment the start pointer, and decrement the end pointer.
Rinse and repeat.
Of course, you can do exactly the same thing using array indices instead of pointers....
looks like a school homework!
This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.