代码示例:

1
2
3
4
5
6
7
8
9
10
/* subst.c -- 在字符串中进行替换 */
#include <stdio.h>
#define PSOR(x) printf("The square of " #x " is %d\n", ((x)*(x)))

int main(void){
int y = 5;
PSOR(y);
PSOR(2 + 4);
return 0;
}

运行结果为:

1
2
The square of y is 25
The square of 2 + 4 is 36