怎样把宏定义拷贝到字符数组中?
...#define SAMPLE_STR helloworld
...
char arr[20];
...
用什么方法将宏SAMPLE_STR填充到arr数组中去?即 arr的内容为 "helloworld".
前提:不许定义成带引号的形式,如:
#define SAMPLE_STR "helloworld"
2012-06-28 23:27
2012-06-28 23:28
2012-06-29 09:08
2012-07-23 23:07
2012-07-24 12:08
程序代码: #define STRING2(x) #x
#define STRING(s) STRING2(s)
#define STR ABC
int main(void) {
char s[4];
strcpy(s,STRING(STR));
printf("%s",s);
return 0;
}

2012-07-24 12:23