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
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