Skip to content

Instantly share code, notes, and snippets.

@nilsding
Created March 10, 2013 20:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nilsding/5130368 to your computer and use it in GitHub Desktop.
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.
#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