------- iOS培训、android培训、java培训、期待与您交流! ----------
/*
宏
自定义的特殊标示符,(习惯大写)
定义
#define宏名 宏字符串(常量/变量/表达式)
注意:一般卸载函数之前
宏替换
编译之前,宏字符串替换 所有宏名
*/
#include <stdio.h>
#define M 10
#define M1 y*y+3*y
#define R 4
#define PI 3.14
#define AREA PI*R*R//嵌套定义
#define S int
#define SP struct Person
void test(){
printf("M = %d\n",M);
}
//#undef M //取消宏定义
void test1(){
printf("M1 = %d\n",M);
}
int main(int argc,const char * argv[]) {
int a[M+2];
printf("%d\n",M);
int y = 3,result = 0;
result = 3 * M1 + 2 * M1 - 50;//3*y*y+3*y+2*y*y+3*y-50
printf("result = %d\n",result);
test();
test();
printf("%.2f\n",AREA);
S a1;
a1 = 10;
printf("a1 = %d\n",a1);
SP{
int age;
};
SP P1 = {23};
return 0;
}