天天看點

C語言#,##執行個體

#include <string.h>

#include <stdio.h>

#include <stdlib.h>

#define toConstStr(a,b) a#b   //a must "xxx", "" is needed.

#define toUserDefine(a,b) a##b

int functionA(int a,int b)

{

       return a+b;

}

int main()

       const char* t=toConstStr("xyz",abc);//轉成常量字元串  如t="xyzabc"

       printf("const str: <%s> \n",t);//output: xzyabc

       int b = toUserDefine(function,A)(5,5);// 轉成文法分析之前的使用者定義名,如b=functionA(5,5);