Last active
August 29, 2015 14:02
-
-
Save honghaoz/c3671861e084dae3beaa to your computer and use it in GitHub Desktop.
ReverseAString
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<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