1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
| #include <string.h>
#include <stdio.h>
int (*foo2 ( void * foo )) [5]
{
static int res [5] ;
memcpy( res,foo,5*sizeof( int )) ;
return & res ;
}
void * foo4 ( void * foo )
{
return foo ;
}
int (* foo3 ( void *(*foo5) (void*foo) , int(*(*foo)(void*foo))[5] )) [10]
{
static int res [10] ;
int data [5] = { 1,2,3,4,5 } ;
int (*res2) [5] ;
int i ;
res2 = foo( foo5( data )) ;
for ( i = 0 ; i < 5 ; ++i ) res[i] = res[i+5] = (*res2)[i] ;
return & res ;
}
typedef int (* (*foo) ( void *(*) (void*foo) , int(*(*foo)(void*foo))[5] ) ) [10] ;
int main(void)
{
int i ;
int (*res) [10] ;
foo f = foo3 ;
res = f( &foo4,&foo2 ) ;
for ( i = 0 ; i < 10 ; ++i ) printf("%d\n",(*res)[i] ) ;
return 0 ;
} |
Partager