Created
February 9, 2021 23:57
-
-
Save weskerfoot/fe88805e544b44f71e88c76e5c0b5566 to your computer and use it in GitHub Desktop.
This file contains hidden or 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> | |
#include <stdlib.h> | |
struct Foo { | |
int a; | |
int arr[]; | |
}; | |
struct Foo* | |
f(int n) { | |
struct Foo *a = calloc(sizeof *a, n * sizeof (int)); | |
a->a = 42; | |
a->arr[n] = 666; | |
a[1].arr[n+2] = 420; | |
a[n].arr[n] = 420666; | |
return a; | |
} | |
int | |
main() { | |
struct Foo *test = f(12); | |
printf("%d\n", test[12].arr[12]); | |
free(test); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment