第八章更新
This commit is contained in:
@@ -17,6 +17,7 @@
|
|||||||
- [函数传参(值,地址)](#函数传参值地址-1)
|
- [函数传参(值,地址)](#函数传参值地址-1)
|
||||||
- [位域](#位域)
|
- [位域](#位域)
|
||||||
- [枚举](#枚举)
|
- [枚举](#枚举)
|
||||||
|
- [typedef](#typedef)
|
||||||
|
|
||||||
|
|
||||||
# 构造类型
|
# 构造类型
|
||||||
@@ -224,3 +225,8 @@ enum 标识符
|
|||||||
};
|
};
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## typedef
|
||||||
|
|
||||||
|
为已有的数据类型改名。
|
||||||
|
|
||||||
|
`typedef 已有的数据类型 新名字;`
|
||||||
57
Chapter8/typedef.c
Normal file
57
Chapter8/typedef.c
Normal file
@@ -0,0 +1,57 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
// #define INT int;
|
||||||
|
|
||||||
|
typedef int INT;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* #define IP int *;
|
||||||
|
* IP p,q; -> int *p, q;
|
||||||
|
*
|
||||||
|
* typedef int *IP;
|
||||||
|
* IP p,q; -> int *p, *q;
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* typedef int ARR[6]; --> int [6] -> ARR
|
||||||
|
*
|
||||||
|
* ARR a; -> int a[6];
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
typedef struct node_st
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
float p;
|
||||||
|
} NODE, *NODEP;
|
||||||
|
|
||||||
|
NODE a; // struct node_st a;
|
||||||
|
NODE *p;
|
||||||
|
|
||||||
|
NODEP p; // struct node_st *p;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* typedef int FUNC(int); --> int(int) FUNC;
|
||||||
|
* FUNC f; --> int f(int);
|
||||||
|
*
|
||||||
|
* typedef int *FUNCP(int);
|
||||||
|
* FUNCP p; --> int *p(int);
|
||||||
|
*
|
||||||
|
* typedef int *(*FUNCP)(int);
|
||||||
|
* FUNCP p; --> int *(*p)(int);
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
INT i = 100; // int i;
|
||||||
|
|
||||||
|
printf("%d\n", i);
|
||||||
|
|
||||||
|
exit(0);
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user