Question
Can someone help me please? Implement three C-String functions char * getPointerToTerminator (char w[]); // return a pointer to the null terminator of w. bool
Can someone help me please?
Implement three C-String functions
char * getPointerToTerminator (char w[]); // return a pointer to the null terminator of w.
bool isPalindrome(char w[]); // return true iff w is a palindrome (e.g. "", "d", "xx", "abba" , "racecar" etc.).
void reverse(char w[]); // reverse the characters in w, not including the null terminator, e.g. "abc" --> "cba".
The isPalindrome and reverse functions should be coded this way: Use two pointers p and q of type char *. p will be initialized to w, and q will be initialized to the address of the last character of w (meaning the character preceding the null terminator). To initialize q you should be calling getPointerTerminator. Next, use a loop that increments p and decrements q, as long as one pointer is less than the other. In the case of isPalindrome, you'll be comparing values at addresses p and q to see if they are equal. In the case of reverse, you'll be swapping values as addresses p and q. One more thing: To practice using pointer notation, don't use any square brackets in your code other than in the function header.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started