make string from macro in C language

#define MKS_(x) #x
#define MKSTRING(x) MKS_(x)

#define M1 "macro 1 macro 1"
#define M2 macro 2


int main()
{
    printf("%s\n",MKSTRING(M1));
    printf("%s\n",MKSTRING(M2));
    printf("%s\n",MKSTRING(string1));
    printf("%s\n",MKSTRING(str str));
    printf("%s\n",MKSTRING(123 456 78 9));
    return 0;
}
posted @ 2012-04-19 11:45  嗷嗷  阅读(411)  评论(0编辑  收藏  举报