Skip to content

Instantly share code, notes, and snippets.

@pchong90

pchong90/1_2.cpp Secret

Created June 17, 2014 02:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pchong90/e48b4175b82883e62780 to your computer and use it in GitHub Desktop.
Save pchong90/e48b4175b82883e62780 to your computer and use it in GitHub Desktop.
#include <string>
#include <iostream>
#include <iterator>
using namespace std;
bool reverse_str(string& str){
if (str.empty()){
return false;
}
string::iterator i,j;
for(i = str.begin(), j = str.end() - 1; i < j; i++, j--){
char tmp = *i;
*i = *j;
*j = tmp;
}
return true;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment