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 /testbed | |
parent | 0ac22f0214ee283ce9bb053d691aeac823f875be (diff) |
rename
Diffstat (limited to 'testbed')
-rw-r--r-- | testbed/custom_const.c | 9 | ||||
-rw-r--r-- | testbed/custom_struct.c | 26 | ||||
-rw-r--r-- | testbed/custom_struct2.c | 41 | ||||
-rw-r--r-- | testbed/custom_struct3.c | 15 | ||||
-rw-r--r-- | testbed/custom_struct4.c | 28 | ||||
-rw-r--r-- | testbed/custom_subexp.c | 9 | ||||
-rw-r--r-- | testbed/custom_subexp2.c | 10 | ||||
-rw-r--r-- | testbed/func_pointer.c | 19 |
8 files changed, 0 insertions, 157 deletions
diff --git a/testbed/custom_const.c b/testbed/custom_const.c deleted file mode 100644 index d0126f3..0000000 --- a/testbed/custom_const.c +++ /dev/null @@ -1,9 +0,0 @@ -int sum;
-void f() {
- sum = 3;
-}
-int main() {
- sum = 1;
- f();
- printf("%d\n", sum);
-}
diff --git a/testbed/custom_struct.c b/testbed/custom_struct.c deleted file mode 100644 index 0d473f5..0000000 --- a/testbed/custom_struct.c +++ /dev/null @@ -1,26 +0,0 @@ -struct D {
- int a, b;
-};
-struct A {
- int a[100];
- struct B {
- struct C {
- int x, y;
- } c;
- int z;
- struct D *p;
- } b;
-} s;
-int main() {
- struct D d;
- int n = 0;
- s.a[1] = 1;
- s.a[2] = 2;
- s.b.z = 4;
- s.b.c.x = 5;
- s.b.c.y = 6;
- s.b.p = &d;
- s.b.p->a = 7;
- s.b.p->b = 8;
- printf("%d %d %d %d %d %d %d\n", s.a[1], s.a[2], s.b.z, s.b.c.x, s.b.c.y, s.b.p->a, s.b.p->b);
-}
diff --git a/testbed/custom_struct2.c b/testbed/custom_struct2.c deleted file mode 100644 index e147186..0000000 --- a/testbed/custom_struct2.c +++ /dev/null @@ -1,41 +0,0 @@ -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);
-}
diff --git a/testbed/custom_struct3.c b/testbed/custom_struct3.c deleted file mode 100644 index d7060b3..0000000 --- a/testbed/custom_struct3.c +++ /dev/null @@ -1,15 +0,0 @@ -struct A { - int x, y; -} a[10]; -struct A f(struct A a) { - a.x++; - a.y++; - return a; -} -int main(){ - int i; - for (i = 1; i < 10; i++) - a[i] = f(a[i - 1]); - for (i = 0; i < 10; i++) - printf("%d %d\n", a[i].x, a[i].y); -} diff --git a/testbed/custom_struct4.c b/testbed/custom_struct4.c deleted file mode 100644 index 75f50ea..0000000 --- a/testbed/custom_struct4.c +++ /dev/null @@ -1,28 +0,0 @@ -struct A {
- struct B {
- int x, y;
- struct C {
- int w;
- } c;
- } b;
- int z;
-};
-
-struct B f(struct A a) {
- printf("z: %d\n", a.z);
- return a.b;
-}
-
-struct C g(struct B b) {
- printf("x: %d\ny: %d\n", b.x, b.y);
- return b.c;
-}
-
-int main() {
- struct A a;
- a.z = 1;
- a.b.x = 2;
- a.b.y = 3;
- a.b.c.w = 4;
- printf("w: %d\n", g(f(a)).w);
-}
diff --git a/testbed/custom_subexp.c b/testbed/custom_subexp.c deleted file mode 100644 index bce5bdb..0000000 --- a/testbed/custom_subexp.c +++ /dev/null @@ -1,9 +0,0 @@ -int N = 0;
-void f() { N = 2; }
-int main() {
- int a, b;
- a = N + 1;
- f();
- b = N + 1;
- printf("%d\n", b);
-}
diff --git a/testbed/custom_subexp2.c b/testbed/custom_subexp2.c deleted file mode 100644 index 1e4af93..0000000 --- a/testbed/custom_subexp2.c +++ /dev/null @@ -1,10 +0,0 @@ -int flag = 0; -int check(int x, int y) { - return x > 0 && y > 0 && (flag ^= 1); -} -int main() { - int x = 1, y = 2; - printf("%d\n", check(x, y)); - printf("%d\n", check(x, y)); - printf("%d\n", check(x, y)); -} diff --git a/testbed/func_pointer.c b/testbed/func_pointer.c deleted file mode 100644 index e7b6484..0000000 --- a/testbed/func_pointer.c +++ /dev/null @@ -1,19 +0,0 @@ -typedef void (*Func_t)(); -void f(Func_t func, int step) { - if (!step) return; - printf("i'm f\n"); - func(func, step - 1); -} -void g(void (*func)(), int step) { - if (!step) return; - printf("i'm g\n"); - func(func, step - 1); -} -int main() { - void (*func)(void (*ifunc)(), int step); - int x = 1; - if (x) func = f; - else func = g; - func(func, 5); - return 0; -} |