All pastes #635511 Raw Edit

Reverse a String

public cpp v1 · immutable
#635511 ·published 2007-07-27 03:59 UTC
rendered paste body
#include <iostream>#include <string>#include <algorithm>int main() {        std::string foo = "nick";        std::cout << "String Forwards: " << foo << std::endl;        // Uses reverse() from algorithm        // The function begin() returns an iterator to the first element of the string.        // The end() function returns an iterator just past the end of the string.        std::reverse( foo.begin(), foo.end() );        std::cout << "String Backwards: " << foo << std::endl;        return 0;}