- 论坛徽章:
- 0
|
A simple test
- #include<stdio.h>
- #include<stdlib.h>
- const int n = 10;
- int *(*(*any2)(int* (*arg)[n]))[n];
- int *(*any(int* (*arg)[n]))[n]
- {
- int i;
- int *(*a)[n];
- a = (int* (*)[n])malloc(sizeof(int* (*)[n]) * n);
- if (a == NULL)
- {
- return NULL;
- }
- for (i = 0; i < n; i++)
- {
- a[0][i] = (int*)((int)(arg[0][i]) + 10);
- }
- return a;
- }
- int main()
- {
- int i;
- int *(*b)[n];
- int *(*c)[n];
- b = (int* (*)[n])malloc(sizeof(int* (*)[n]) * n);
- if (b == NULL)
- {
- printf("malloc b error\n");
- exit(1);
- }
- for (i = 0; i < n; i++)
- b[0][i] = (int*)(i+1000);
- any2 = any;
- c = any2(b);
- if (c != NULL)
- {
- for (i = 0; i < n; i++)
- {
- printf("%d,%d\n", (int)b[0][i], (int)c[0][i]);
- }
- }
- else
- printf("any error\n");
- return 0;
- }
复制代码 |
|