#include <iostream> #include <string> #include <stack> #include <cstring> using namespace std; int main() { int i=0; string text; stack<char> s; cout<<"Enter a string: "; cin>>text; for(int i=0;i<text.length();i++) { //text.length takes only one word and doesn't count whitespaces. s.push(text[i]); } while(!s.empty()) { cout<<s.top(); s.pop(); }
text.c_str()
stack<char>
stack<char> s = new stack<char>();
for (int i=text.length()-1; i>=0; i--)
getline(cin,text,'\n')
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)