Hi, I was doing my assignment which states:
The user to enter a string which should be stored in Input_String[].
2) Then reverse the string and save it to another array called Output_String[].
I am having trouble with the second part where I need to save the string to another array. I am not sure how would I do. Here is what I have done:
// Hw-4_Bhasin.cpp : Defines the entry point for the console application.
//void rev_str();
#include "stdafx.h"
#include<iostream>
#include<string>
#include<cmath>
using namespace std;
int main()
{
char option;
void rev_str();
double Mean(const int Data[5][4], int, int);
void frequency(const int Data[5][4], int, int);
cout<<"\n Please choose from the given menu.";
cout<<"\n R{Reverse String] M[Matrix] Q[Quit]."<<endl;
cin>> option;
cin.ignore();
switch(option)
{
case 'R':
case 'r':
rev_str();
break;
}
system("pause");
return 0;
}
void rev_str()
{
const int MAX = 20;
char Input_String[MAX];
char Output_String[MAX];
cout<<"Please enter a string."<<endl;
cin.get(Input_String, MAX);
for(int i=MAX; i>=0; i--)
cout<<Input_String[i]<<endl;
Output_String = Input_String; // ERROR: LEFT OPERAND MUST BE 1-VALUE.
system("pause");
return;
}
Thanks.