我尝试用一些东西填充联合的内容,但是我收到一个错误。这是代码:
struct command
{
int type;
int *input;
int *output;
union{
struct command *command[2];
char **word;
}u;
};
typedef struct command *command_t;
command_t read_command(){
command_t main1 = NULL;
command_t main2 = NULL;
main1->u->word = (char**)malloc(1);
main1->u->word[0] = (char*)malloc(1);
//some other code in here
}
“main1->u->word = (char**)malloc(1);”中出现错误 行说:“无效的类型参数â->â(有âunionâ)”
有什么建议吗?谢谢