Created
September 8, 2016 08:58
-
-
Save raek/738b6395d12bc1972fb6f05dea495969 to your computer and use it in GitHub Desktop.
Puzzle of the Week #5: C'ing is believing
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> | |
/* Run like this: | |
* gcc -Wall -Wextra puzzle5.c && ./a.out | |
*/ | |
/* TODO: remove these weird unused functions */ | |
long int g(long int x) { | |
return x; | |
} | |
typedef long int (*int_to_int)(long int); | |
int_to_int f(long int x) { | |
(void) x; /* unused */ | |
return g; | |
} | |
/* Some "convenience" macros for "field" offsets */ | |
#define ALPHA(f) ((long int) f + 0) | |
#define BETA (f) ((long int) f + 1) | |
#define GAMMA(f) ((long int) f + 2) | |
int main(int argc, char **argv) | |
{ | |
long int values[10] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; | |
long int field = 3; | |
(void) argc; /* unused */ | |
(void) argv; /* unused */ | |
printf("%ld, %ld, %ld\n", | |
values[ALPHA(field)], | |
values[BETA(field)], | |
values[GAMMA(field)]); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment