宏定义转字符串

#include 

#define ZERO    "0"
#define ONE     1
#define STR1(R) #R
#define STR2(R) STR1(R)

int main()
{
    printf("%s\n", ZERO);
    printf("%s\n", STR1(ZERO));
    printf("%s\n", STR2(ZERO));
    printf("%s\n", STR1(ONE));
    printf("%s\n", STR2(ONE));
	
	return 0;
}

输出

0
ZERO
"0"
ONE
1

你可能感兴趣的:(c/c++)