#include "stdafx.h"
#include <iostream>
#include <iomanip>
#include <string>
using namespace std;
char your_string[256];
char new_string[256];
void ReverseString();
int main()
{
char choice;
do
{
cout <<"Enter the string that you want to reverse: \n";
cin.getline(your_string, 256);
ReverseString();
cout << new_string << "\n";
cout <<"Do you want to continue? Press e to exit: ";
cin>>choice;
cin.ignore(1000,'\n');
}
while (choice != 'e');
return 0;
}
void ReverseString()
{
for(int i=0;i<256;(new_string[i]=0),i++);
int x = strlen(your_string)-1;
for(int y = x; y >= 0; y--)
{
new_string[x-y] = your_string[y];
}
}
I have this program that reverses strings but it is using Global arrays but the instructor doesnt want it like but using reference or static. Pass the string from main to the function using reference or static. Example: void ReverseString(string& st). Thank you for your help.