Skip to content

Instantly share code, notes, and snippets.

@yasuharu519
Created January 17, 2013 16:10
Show Gist options
  • Save yasuharu519/4557078 to your computer and use it in GitHub Desktop.
Save yasuharu519/4557078 to your computer and use it in GitHub Desktop.
#include <cstdio>
#include <iostream>
#include <vector>
using namespace std;
void reverse(char *str){
char* end = str;
char tmp;
if(str){
while(*end){
++end;
}
--end;
while(str < end){
tmp = *str;
*str++ = *end;
*end-- = tmp;
}
}
}
int main(){
string input;
vector<char> str;
while(cin >> input){
cout << input << endl;
str.assign(input.c_str(), input.c_str() + input.size());
//str = vector<char>(input.begin(), input.end());
reverse(&str[0]);
cout << (char*)&str[0] << endl;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment