//: C01:RevStr.cpp // From Thinking in C++, 2nd Edition // Available at http://www.BruceEckel.com // (c) Bruce Eckel 2000 // Copyright notice in Copyright.txt // Print a string in reverse #include #include using namespace std; int main() { string s("987654321"); // Use this iterator to walk backwards: string::reverse_iterator rev; // "Incrementing" the reverse iterator moves // it to successively lower string elements: for(rev = s.rbegin(); rev != s.rend(); rev++) cout << *rev << " "; } ///:~