您的位置:首页 > 其它

预处理...

2016-01-02 07:24 155 查看




#include <stdio.h>
struct Student {
char * name;
int age;
};

#define Student struct Student

#define SUM(a) (a + a)

#define MULTIPLY(a, b) (a * b)

#define mPrintf(a) printf("a = %d\n", a)

// 宏定义多个语句.
#define M3(m, n) \
m = c + 2; \
n = c * 2;

#define MAX(a, b) a > b ? a : b

int main(int argc, const char * argv[])
{
// #define M 10
// #undef M

Student stu = { "项羽", 55 };

printf("%s,%d\n", stu.name, stu.age);

int a = SUM(3);
printf("%d\n", a);

int b = MULTIPLY(3, 4);
printf("%d\n", b);
mPrintf(b);

// 宏定义多个语句.
int c = 5;
int m, n;
M3(m, n);

printf("%d %d\n", m, n);

//************************ stone ***

int max = MAX(55, 116);
printf("%d\n", max);

int i = 55, j = 116;
int mm = i > j ? i : j;
printf("%d\n", mm);

return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: