Created
May 14, 2012 15:23
-
-
Save mansr/2694556 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 <stdio.h> | |
static void foo(void) | |
{ | |
puts("hello world"); | |
} | |
struct { | |
const int *data; | |
void (*func)(void); | |
} bar = { | |
(const int []){ 0 }, | |
foo, | |
}; | |
int main(void) | |
{ | |
bar.func(); | |
return 0; | |
} |
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> | |
struct { | |
const int *data; | |
int a; | |
} bar = { | |
(const int []){ 0 }, | |
42, | |
}; | |
int main(void) | |
{ | |
printf("%d\n", bar.a); | |
return 0; | |
} |
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> | |
struct { | |
const int *data; | |
int a; | |
} bar = { | |
(const int []){ 0 }, | |
42, | |
}; | |
int main(void) | |
{ | |
printf("%d\n", bar.data[0]); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment