Created
March 10, 2013 20:54
-
-
Save nilsding/5130368 to your computer and use it in GitHub Desktop.
I made this for @codepony. Pretty useless if you don't know what it is useful for.
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 <stdio.h> | |
#include <string.h> | |
void reverse(char* s) | |
{ | |
int i, j; | |
char c; | |
for (i = 0, j = strlen(s) - 1; i < j; i++, j--) | |
{ | |
c = s[i]; | |
s[i] = s[j]; | |
s[j] = c; | |
} | |
} | |
int main(int argc, char** argv) | |
{ | |
if (argc != 2) { | |
printf("Usage: %s TEXT\n", argv[0]); | |
return 1; | |
} | |
int i, j = strlen(argv[1]); | |
int a[j]; | |
reverse(argv[1]); | |
printf("["); | |
for (i = 0; i < j; i++) { | |
a[i] = 0xFF - argv[1][i]; | |
printf("%d, ", a[i]); | |
} | |
printf("\b\b]\n"); | |
return 0; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment