I am very new to programming. My question may be silly but it will be helpful if someone can guide me.
Please see my code below:
#include <iostream>
#include <string>
using namespace std;
int main()
{
cout << "you have choose to Reverse the text" << endl;
string inputstring;
string outputstring;
cout << "Enter the string you want to reverse" << endl;
getline(cin, inputstring);
int n = inputstring.length();
for (int i = 0; i < n; i++)
{
outputstring[i] = inputstring[n - 1 - i]; // problem in this line
}
}
Till here it works fine inputstring[n - 1 - i] but when I try to assign its value to outputstring. I am getting error.