Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@jric
Created April 3, 2014 23:06
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 jric/9964635 to your computer and use it in GitHub Desktop.
Save jric/9964635 to your computer and use it in GitHub Desktop.
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
typedef struct _Buff_t {
int a;
} Buff_t;
static const char *msg = "\n!dlroW olleH";
void setup(Buff_t **d) {
*d = malloc(sizeof(Buff_t) * strlen(msg) + 1);
for (int i = 0; i < strlen(msg); i++)
(*d)[i].a = strlen(msg) - i - 1;
}
void run(Buff_t *d) {
int i = 0;
while (msg[d[i++].a]) { printf("%c", msg[d[i++].a]); }
}
void cleanup(Buff_t *d) {
free(d);
}
int main() {
Buff_t *d = 0;
setup(&d);
run(d);
cleanup(d);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment