Skip to content

Instantly share code, notes, and snippets.

@honghaoz
Last active August 29, 2015 14:02
Show Gist options
  • Save honghaoz/c3671861e084dae3beaa to your computer and use it in GitHub Desktop.
Save honghaoz/c3671861e084dae3beaa to your computer and use it in GitHub Desktop.
ReverseAString
#include<iostream>
using namespace std;
void reverse(char a[]) {
int length = strlen(a);
char temp;
for (int i = 0; i < length / 2; i++) {
temp = a[i];
a[i] = a[length - 1 - i];
a[length - 1 - i] = temp;
}
}
int main() {
char b[] = "12345";
reverseString(b);
printf("%s", b);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment