我有两个结构,如下所示
struct server{
// some members
};
struct msg{
struct server* servers;
};
然后我这样做。
struct msg msg1;
struct server s1,s2;
msg1.servers = (struct server *)malloc(2*sizeof(struct server));
msg1.servers[0] = &s1; // compilation error
msg1.servers[1] = &s2; // compilation error
此代码无法编译并给出以下错误:从类型“struct server *”分配给类型“struct server”时类型不兼容。
我究竟做错了什么?