c/c++ # 与 ##

c++   # x  表示 将 x 变量  变成 字符串

c++ a##1 表示 连接的意思,

下面 上代码:

// testjin.cpp : 定义控制台应用程序的入口点。
//

#include "stdafx.h"

#define test(a) printf("hello"#a)
#define	testjj(a) printf("%d",a##_1)

int _tmain(int argc, _TCHAR* argv[])
{
	test(c++sfsfs);
	printf("\n");
	int x_1 = 1000;
	testjj(x);
	return 0;
}

输出:

helloc++

1000

版权声明:本文为博主原创文章,未经博主允许不得转载。

时间: 2024-08-24 12:23:23