Question: I wrote this code to read string in revers, but for some reason it doesn't want to read it right. Can you tell me what
I wrote this code to read string in revers, but for some reason it doesn't want to read it right. Can you tell me what is the issue;
#include
#include
#include
using namespace std;
int main() {
string uText;
string otvet = "";
cin >> uText;
int x = uText.size()-1;
getline(cin, uText);
while (uText == "Quit" || uText == "quit" || uText == "q") {break;}
for(int i = x ; i >= 0; --i)
{
otvet.push_back(uText.at(i));
}
cout << otvet << endl;
return 0;
}
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
