i want to type in a word and for my program to output it backwards. but i have to use an iterator.
ex: "clue" and it should print it out "eulc"
this is what i have so far.
Code:#include <iostream> #include<string> using namespace std; int main(){ string s; cout << "Enter a word: "; getline( cin, s ); string::iterator r; r = s.begin(); while ( r != s.end() ){ cout<< *r; r++; } cout<<endl; return (0); }




Reply With Quote