关于宏和逗号表达式

宏是C编译系统的预处理,何谓“预”?即是正式工作开始之前的准备工作。所以宏替换是在对程序编译之前进行的~也就是直接将宏定义的字符,转换成后面的表达式。

逗号表达式:逗号运算符,优先级别最低,它将两式联接起来,可连续执行

代码:直接对文件输出1-1000的数字

#include <stdio.h>
#define B P,P,P,P,P,P,P,P,P,P
#define P L,L,L,L,L,L,L,L,L,L
#define L I,I,I,I,I,I,I,I,I,I,N
#define I fprintf(f,"%3d
",i++)
#define N fprintf(f,"
")

int main(){
    FILE* f=fopen("/home/wuzengxiong/out.txt","w");
    int i=1;
    B;
    return 0;
}


原文地址:https://www.cnblogs.com/fightformylife/p/4343168.html