我所试图做的就是创建结构的数组,并通过函数初始化但是我得到了一些错误,阵列由函数初始化结构的
lab2.c:20:2: error: declaration of anonymous struct must be a definition
struct *person users[] = userInput();
^
lab2.c:20:2: warning: declaration does not declare anything[-Wmissing-declarations]
struct *person users[] = userInput();
^~~~~~
lab2.c:24:1: error: declaration of anonymous struct must be a definition
struct * userInput() {
^
lab2.c:48:2: error: expected identifier or '('
}
^
1 warning and 3 errors generated.
下面是我的代码,在冷凝版本,如果需要更多,请告诉我,我对C很新,所以我猜这是我的一个明显的错误。
int main() {
struct person users = userInput();
return 0;
}
struct * userInput() {
struct person users[30];
...do stuff to struct here...
return *users;
}
用户是一个结构。 userInput返回一个struct *。 –
您的退货类型无效。 'struct *'不是数据类型。 –