Created
April 3, 2014 23:06
-
-
Save jric/9964635 to your computer and use it in GitHub Desktop.
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 <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