程序源码
# include <stdio.h>
# if 1
int add ( int x, int y)
{
return ( x+ y) ;
}
int main ( )
{
char ch1 = 'w' ;
char * p = & ch1;
const char * p2 = "abcdef" ;
int * arr[ 10 ] ;
char * ch2[ 5 ] ;
int arr2[ 5 ] ;
int ( * pa) [ 5 ] = & arr2;
int ( * padd) ( int , int ) = add;
int sum = padd ( 1 , 3 ) ;
printf ( "sum = %d\n" , sum) ;
int ( * parr1[ 5 ] ) ( int , int ) ;
int ( * ( * pparr) [ 5 ] ) ( int , int ) = & parr1;
return 0 ;
}
# endif
# if 1
# include <stdio.h>
int main ( )
{
void test1 ( int arr1[ ] )
{
}
void test2 ( int arr1[ 10 ] )
{
}
{
void test3 ( int * arr1)
{
}
void test4 ( int * arr2[ 20 ] )
{
}
void test5 ( int * * arr2)
{
}
int arr1[ 10 ] = { 0 } ;
int * arr2[ 20 ] = { 0 } ;
test1 ( arr1) ;
test5 ( arr2) ;
return 0 ;
}
}
# endif
# if 1
# include <stdio.h>
int main ( )
{
void test1 ( int arr[ 3 ] [ 5 ] )
{
}
void test2 ( int arr[ ] [ 5 ] )
{
}
void test3 ( int arr[ 3 ] [ ] )
{
}
void test4 ( int arr[ ] [ ] )
{
}
void test5 ( int * arr)
{
}
void test6 ( int * * arr)
{
}
void test7 ( int ( * arr) [ 5 ] )
{
}
int arr[ 3 ] [ 5 ] = { 0 } ;
test1 ( arr) ;
return 0 ;
}
# endif
# if 1
# include <stdio.h>
int main ( )
{
void test1 ( int * p)
{
}
void test2 ( char * p)
{
}
int a = 10 ;
int * p1 = & a;
test1 ( & a) ;
test1 ( p1) ;
char ch = 'w' ;
char * pc = & ch;
test2 ( & ch) ;
test2 ( pc) ;
return 0 ;
}
# endif
# if 1
# include <stdio.h>
int main ( )
{
void test ( int * * p)
{
}
int * ptr;
int * * pp = & ptr;
test ( & ptr) ;
test ( pp) ;
int * arr[ 10 ] ;
test ( arr) ;
return 0 ;
}
# endif
# if 0
# include <stdio.h>
int main ( )
{
int add ( int x, int y)
{
return ( x+ y) ;
}
int a = 10 ;
int b = 20 ;
printf ( "%d\n" , add ( a, b) ) ;
printf ( "%p\n" , & add) ;
printf ( "%p\n" , add) ;
printf ( "%p\n" , "qwer" ) ;
printf ( "%p\n" , & "qwer" ) ;
int ( * pa) ( int , int ) = add;
printf ( "%d\n" , pa ( 2 , 3 ) ) ;
printf ( "%d\n" , ( * pa) ( 2 , 3 ) ) ;
printf ( "%d\n" , ( * * pa) ( 2 , 3 ) ) ;
printf ( "%d\n" , ( * * * pa) ( 2 , 3 ) ) ;
return 0 ;
}
# endif
# if 0
# include <stdio.h>
int main ( )
{
void print ( char * str)
{
printf ( "%s\n" , str) ;
}
void ( * p) ( char * ) = print;
( * p) ( "Hello" ) ;
return 0 ;
}
# endif
# if 1
# include <stdio.h>
int main ( )
{
( * ( void ( * ) ( ) ) 0 ) ( ) ;
void ( * signal ( int , void ( * ) ( int ) ) ) ( int ) ;
typedef unsigned int uint;
typedef void ( * pfun_t ) ( int ) ;
pfun_t signal ( int , pfun_t ) ;
return 0 ;
}
# endif
# if 0
# include <stdio.h>
int main ( )
{
int add ( int x, int y)
{
return x+ y;
}
int sub ( int x, int y)
{
return x- y;
}
int mul ( int x, int y)
{
return x* y;
}
int div ( int x, int y)
{
return x/ y;
}
int ( * parr[ 4 ] ) ( int , int ) = { add, sub, mul, div} ;
int i = 0 ;
for ( i= 0 ; i< 4 ; i++ )
{
printf ( "%d\n" , ( * parr[ i] ) ( 2 , 3 ) ) ;
}
return 0 ;
}
# endif
# if 0
# include <stdio.h>
int main
{
int ( * parr1[ 10 ] ) ( ) ;
int * parr2[ 10 ] ( ) ;
int ( * ) ( ) parr3[ 10 ] ;
return 0 ;
}
# if 1
# include <stdio.h>
int main ( )
{
char * my_strcpy ( char * dest, const char * src)
{
}
char * ( * pf) ( char * , const char * ) = my_strcpy;
char * ( * pfarr[ 4 ] ) ( char * , const char * ) = { my_strcpy, my_strcpy, my_strcpy, my_strcpy} ;
return 0 ;
}
# endif
# if 0
# include <stdio.h>
int add ( int x, int y)
{
return x+ y;
}
int main ( )
{
int arr[ 10 ] = { 0 } ;
int ( * p) [ 10 ] = & arr;
int ( * pfarr[ 4 ] ) ( int , int ) = { add} ;
int ( * ( * ppfarr) [ 4 ] ) ( int , int ) = & pfarr;
return 0 ;
}
# endif
# if 1
# include <stdio.h>
void print ( char * str)
{
printf ( "hehe:%s\n" , str) ;
}
void test ( void ( * p) ( char * ) )
{
printf ( "test\n" ) ;
p ( "bit" ) ;
}
int main ( )
{
test ( print) ;
return 0 ;
}
# endif
# if 1
# include <stdio.h>
int main ( )
{
int a = 10 ;
int * pa = & a;
char * pc = & a;
void * p = & a;
p++ ;
return 0 ;
}
# endif
# include <stdio.h>
int main ( )
{
int a[ ] = { 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 } ;
int i = 0 ;
int n = sizeof ( a) / sizeof ( a[ 0 ] ) ;
int * p = a+ n- 1 ;
for ( i= 0 ; i< n; i++ )
{
printf ( "%d," , * p) ;
p-- ;
}
putchar ( '\n' ) ;
return 0 ;
}
# include <stdio.h>
int main ( )
{
int a[ ] = { 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 } ;
int * p2 = & a[ 2 ] ;
int * p1 = & a[ 1 ] ;
int * p0 = & a[ 0 ] ;
printf ( "p0 = %p, p1 = %p, p2 = %p\n" , p0, p1, p2) ;
int n0 = p2 - p0;
int n3 = ( int ) p2 - ( int ) p0;
int n1 = p2 - p1;
int n2 = ( int ) p2 - ( int ) p1;
printf ( "n0 = %d, n3 = %d\n" , n0, n3) ;
printf ( "n1 = %d, n2 = %d\n" , n1, n2) ;
return 0 ;
}