首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C语言 >

超简单的define,居然不会写,该如何处理

2012-02-21 
超简单的define,居然不会写#defineHELLO(x)\helloworld(x) \(x)isafool intmain(){char*cHELLO( bl

超简单的define,居然不会写
#define   HELLO(x)   \
        "hello   world(x) "   \
        "   (x)   is   a   fool; "

int   main()  
{
        char   *c   =   HELLO( "blue ");
        printf( "%s ",c);  
我期望输出 "hello   world   blue   blue   is   a   fool; "
}
如何搞?

[解决办法]
#define HELLO(x) "hello world " x " " x " is a fool; "
[解决办法]
#define HELLO(x) "hello world " x " " x " is a fool; "

"hello world " <==> "hello " " world "
[解决办法]
#include <stdio.h>

#define HELLO(x) "hello world "##x## " "##x## " is a fool; "

int main()
{
char *c = HELLO( "blue ");
printf( "%s\n ",c);

return (0);
}

热点排行