1
#define MALLOC(n, type) (type*)malloc(n*sizeof(type))
#define PRINT(mode, x) printf("The value of "#x" = "mode, x)
上面这行代码的功能: 以 mode 的形式打印 x 的值
12
int a = 1;PRINT("%d", a);
上面的输出:
The value of a = 1
也就是变量的名字会以字符串的形式替换掉 #x
#define contact(a, b) printf("%c", a##b)
很怪就对了,连接传入的字符,一般可以把变量名字拆开再传进去, 会自动连接该变量名 😂