Reverse a String
public cpp v1 · immutable#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;}