Skip to content

Instantly share code, notes, and snippets.

@astkaasa
Created March 17, 2013 16:26
Show Gist options
  • Save astkaasa/5182274 to your computer and use it in GitHub Desktop.
Save astkaasa/5182274 to your computer and use it in GitHub Desktop.
#include <iostream>
using namespace std;
void reverse(char* str){
char* end = str;
char temp;
while(*end != '\0'){
end++;
}
end--;
while(end > str){
temp = *end;
*end = *str;
*str = temp;
str++;
end--;
}
}
int main() {
char str1[] = "This is a test.";
reverse(str1);
cout << str1 << endl;
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment