数据结构二:typedef 和#define

【typedef】

理解为给现有的数据类型起个新名字

eg:

 1 .【typedef struct {...}typeA;】

typeA即为“struct{..}”的新名字

2.【typedef int A;】

这样定义后,A a;就相当于 int a;

【 #define】

#define maxsize 50

int a[maxsize];//maxsize是预先定义的变量 ,值为50

#空指令,无任何效果
#include包含一个源代码文件
#define定义宏
#undef取消已定义的宏
#if如果给定条件为真,则编译下面代码
#ifdef如果宏已经定义,则编译下面代码
#ifndef如果宏没有定义,则编译下面代码
#elif如果前面的#if给定条件不为真,当前条件为真,则编译下面代码
#endif结束一个#if……#else条件编译块
#error停止编译并显示错误信息

猜你喜欢

转载自blog.csdn.net/qq_36013788/article/details/81062965
今日推荐