#include <iostream>
// printf()返回值为输出打印字符的个数
// 利用宏参数创建字符串
#define SQUARE(x) (printf(""#x" square is: %d\n", (x) * (x)))
int main()
{
SQUARE(2+4);
}
- 也可以这么写
#include <iostream>
// printf()返回值为输出打印字符的个数
// 利用宏参数创建字符串
#define SQUARE(x) (printf("%d square is: %d\n",(x), (x) * (x)))
int main()
{
SQUARE(2+4);
}