string s = "hello i am hoge"; stack<char> st; for(int i=0; i<s.size(); i++){ st.push( s[i] ); } string t = ""; while(!st.empty()){ t+=st.top(); st.pop(); } cout << t << endl;
stringの1要素がcharであるとか、
top()で参照、pop()で取り除くとか、
stackを使ってreverseできることなどを覚えよう。
(上記事のreverse()で済むけれども。。