-
-
Save pchong90/e48b4175b82883e62780 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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