首页未分类 › 宏定义转字符串

宏定义转字符串

 

#include <stdio.h>

#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

发表评论