typedef
typedef struct abcdef* af;
// struct abcdef* af 和 struct abcdef *af 没有区别
struct abcdef
{
int nub;
};
此时 af 相当于 struct abcdef*,
即af 为 struct abcdef*的别名
//**typedef **可以用于未完全定义的结构体
typedef long bit_4;
long a;// 1
bit_4 a;// 2
用bit_4代替了long
1 和 2 两种写法效果相同
#define
用法基本与typedef相同
不过**#define**为文本替代
#define pStr2 char*
pStr2 a;// 1
char* a;// 2
此时 1 和 2 效果相同
两者差别
typedef char* pStr1;
#define pStr2 char*
pStr1 s1,s2;
pStr2 s3,s4;
此时 s1, s2, s3 为指针,s4是字符类型。
即:
char* s1, *s2;//别名
char* s3, s4;//文本替代
//萌新自学,如有错误请大佬指正。