diff options
author | Teddy <ted.sybil@gmail.com> | 2014-05-07 03:17:32 +0800 |
---|---|---|
committer | Teddy <ted.sybil@gmail.com> | 2014-05-07 03:17:32 +0800 |
commit | 52b29440f8f1310e0c074c8eb409e433c56bdd62 (patch) | |
tree | 6d91ceeb6594fe337541ed3f9f50cd33ee8881ca /compile_data/custom_struct2.c | |
parent | 0ac22f0214ee283ce9bb053d691aeac823f875be (diff) |
rename
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);
+}
|