当前位置:网站首页>C language elementary level (10) type rename typedef

C language elementary level (10) type rename typedef

2022-06-21 13:22:00 Princess Kaka

One . Basic type rename

typedef  type   New name ;

Two . Structure / Consortium type rename

typedef struct {
     member ;
}  Type name ;

stay typedef Define the structure at the same time , Structure pointer can be defined .

typedef struct{
 int x;
 int y;
 int z;  
} Point3D,*pPoint3D;
Point3D p = {1,2,3};
pPoint3D q = &p;

3、 ... and . Function pointer type rename

typedef  Return type  (*  Function pointer type )( Parameters )

example :

int add(int a,int b){return a+b;}
typedef int (*opt)(int,int); //  Define function pointer type 
opt fpadd = &add; //  Define function pointers and assign values 
printf("%d\n",(*fpadd)(1,3));

原网站

版权声明
本文为[Princess Kaka]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/172/202206211055026868.html