|
发表于 2003-4-24 03:22:46
|
显示全部楼层
最初由 zhyi100 发布
呵呵
define TYPE_INT 0;
define TYPE_STR 1;
struct st
{
int type;
union
{
int num;
char data[];
}danu;
struct st *next;
}
- ...
- void demo_function(sturct st* p)
- {
- if (p->type == TYPE_INT)
- printf("%d\n", p->danu.num);
- else if (p->type == TYPE_STR)
- printf("%s\n", p->danu.data);
- else
- printf("WHAT?\n");
- }
复制代码 |
|