#include <stdlib.h>
#include <stdio.h>
#include <stdarg.h>
#define IsMan(name) pr_value(#name, name) //關鍵點在於#name,會將"\""+name+"\""創給pr_value
#define WANGYONG 1
#define YONGXIN 2
void pr_value(char* name, int type)
{
switch(type)
{
case WANGYONG:
printf("%s\n", name);
break;
case YONGXIN:
printf("%s\n", name);
break;
}
}
int main()
{
IsMan(WANGYONG);
IsMan(YONGXIN);
system("pause");
return 0;
}
摘自 RunBoying