I wrote a simple C++ program to reverse a string. I store a string in character array. To reverse a string I am using same character array and temp variable to swap the char
If I were you, I would just write it like so:
int main() { string str; cout << "Enter a string: " << endl; getline(cin, str); for (int x = str.length() - 1; x > -1; x--) { cout << str[x]; } return 0; }
This is a very simple way to do it and works great.