Skip to content

Instantly share code, notes, and snippets.

@momer
Created April 15, 2013 19:03
Show Gist options
  • Save momer/5390483 to your computer and use it in GitHub Desktop.
Save momer/5390483 to your computer and use it in GitHub Desktop.
# include <stdio.h>
int main() {
char str[] = "Reverse me!";
int length;
for (length = 0; str[length] != '\0'; length++) {
}
printf("length => %d chars\n", length);
int j, k, i;
char c;
for (i = 0, k = length - 1; i < k; i++, k--){
c = str[k];
str[k] = str[i];
str[i] = c;
}
printf("reversed => %s\n", str);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment