Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Professional Microsoft SQL Server 2014 Administration

Authors: Adam Jorgensen, Bradley Ball

1st Edition

111885926X, 9781118859261

More Books

Students also viewed these Databases questions

Question

13-6 How will MIS help my career?

Answered: 1 week ago

Question

13-4 What are alternative methods for building information systems?

Answered: 1 week ago