2
所以我有以下两种结构在结构体中初始化一个结构体?
typedef struct clienttable {
vartable head;
vartable tail;
} clienttable;
typedef struct vartable {
int tableid;
int randominfo;
struct vartable *next;
} vartable;
,我想他们initizalite这样。
clienttable *maintable;
maintable = (clienttable *) malloc (sizeof(clienttable));
maintable->head = {.tableid = 10, .randominfo=NULL, .next=NULL};
,但是当我去编译我不断收到一个
expected expression before { token
错误。我也试过{10,NULL}
也无济于事。
我在做什么错?
另外,我需要malloc
这两个clientable
和客户端表内的所有表,或将只是malloc
ing一个工作?
使用C99,C11或更旧的东西? – chux
我觉得99,但如果有必要,我可以切换到其他东西。 – dcousina