C/C++ 利用宏参数创建字符串 2025-06-11 技术 代码示例: 12345678910/* 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;} 运行结果为: 12The square of y is 25The square of 2 + 4 is 36 最后更新时间:2025-06-11 11:02:31 永久链接:https://blog.gowhich.com/2025/06/11/C-C++-%E5%88%A9%E7%94%A8%E5%AE%8F%E5%8F%82%E6%95%B0%E5%88%9B%E5%BB%BA%E5%AD%97%E7%AC%A6%E4%B8%B2.html 赏 Prev C/C++ 预处理器的粘合剂:##运算符 Next C/C++ 联合(union)及联合(union)与结构体(struct)的区别