This is basically what the problem looks like (the characters aren't actual equal signs, but similar):
Enter string to reverse: AMAZING
Reversed string: ===============GNIZAMA
Do you want to insert another string (Y/N)?: Y
Enter string to reverse: NEVER
Reversed string: ====================REVENMA
Do you want to insert another string (Y/N)?: N
Here is my code:
Enter string to reverse: AMAZING
Reversed string: ===============GNIZAMA
Do you want to insert another string (Y/N)?: Y
Enter string to reverse: NEVER
Reversed string: ====================REVENMA
Do you want to insert another string (Y/N)?: N
Here is my code:
#include <iostream> #include <string.h> using namespace std; void Reverse(char *str); int main() { char user_input[40]; char new_input[40]; char next_item; do { cout << "Enter string to reverse: "; cin.getline(user_input, 40); Reverse(user_input); cout << "Reversed String: " << new_input << endl; cout << "Do you want to insert another string (Y/N)? "; cin >> next_item; cin.ignore(); } while (next_item == 'Y' || next_item == 'y'); return 0; } void Reverse(char *str) { int x = strlen(str); for(int y = x; y >= (x/2)+1; y--) { swap(str[x-y],str[y-1]); } }