Question: C++ Write a program that accepts a C-string input from the user and reverses the contents of the string. Your program should work by using
C++
Write a program that accepts a C-string input from the user and reverses the contents of the string.
Your program should work by using two pointers. The "head" pointer should be set to the address of the last character in the string, and the "tail" pointer should be set to the address of the last character in the string(i.e.,the character before the terminating null).
The program should swap the characters referenced by the pointers, increment "head" to point to the next character , decrement "tail" to point to the second-to-last character, and so on, until all characters have been swapped and the entire string reversed.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
