diff options
Diffstat (limited to 'compile_data/custom_struct2.c')
-rw-r--r-- | compile_data/custom_struct2.c | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/compile_data/custom_struct2.c b/compile_data/custom_struct2.c new file mode 100644 index 0000000..e147186 --- /dev/null +++ b/compile_data/custom_struct2.c @@ -0,0 +1,41 @@ +struct A { + int x, y; +} sa; +struct A print(struct A a, struct A b) { + a.x++; + a.y++; + b.x--; + b.y--; + printf("args: %d %d\n", a.x, a.y); + printf("args: %d %d\n", b.x, b.y); + return a; +} +int main() { + int i; + int t; + int *a, *b; + struct A sb, sc; + a = malloc(sizeof(int) * 100); + for (i = 0; i < 100; i++) + a[i] = i; + b = malloc(sizeof(int) * 100); + memcpy(b, a, sizeof(int) * 100); + for (i = 0; i < 100; i++) + printf("%d ", b[i]); + sb.x = 1; + sb.y = 2; + sa = sb; + sc = sa; + printf("\n%d %d\n", sa.x, sa.y); + printf("%d %d\n", sc.x, sc.y); + sa.x = 1; + sa.y = 2; + sb.x = 1; + sb.y = 2; + sa = print(sa, sb); + sb = print(sa, sb); + sa = print(sa, sb); + sb = print(sa, sb); + printf("%d %d\n", sa.x, sa.y); + printf("%d %d\n", sb.x, sb.y); +} |