我想做的是创建一个结构数组,并通过一个函数对其进行初始化,但是我遇到了一些错误,
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;
}