Question: 1. Using a loop, determine the size of the string by counting characters until you encounter the null terminating character at the end of the

1. Using a loop, determine the size of the string by counting characters until you encounter the null terminating character at the end of the string.

2. Establish a pointer that points to the beginning character of the string.

3. Establish a pointer that points to the last character in the string, this is the character just before the null terminating character.

4. Using the pointers, swap the first character in the string and the last character in the string.

5. Move the pointers so that the first pointer points to the 2nd character in the string and the second pointer points to the next to last character in the string. Swap these two characters.

6. Repeat this process until all of the characters have been swapped. The string should now be reversed. Add this driver code to your program:

int main( ) { // declare a c-string to reverse char myString[ ] = "Hello world!"; // call the reverser function reverser(myString); // output the result cout << myString << endl; system("PAUSE"); return 0; }

Submit

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!