我无法在主程序中使用 make_employee 函数返回的指针。
// 我在一个单独的 .c 文件中有以下代码:
struct Employee;
struct Employee* make_employee(char* name, int birth_year, int start_year){
struct Employee* new = (struct Employee*)malloc(sizeof(struct Employee));
strcpy(new->name, name);
new->birth_year = birth_year;
new->start_year = start_year;
return new;
}
//In the main program:
int main()
{
char test_name[] = "Fred";
int test_birth = 1989;
int test_start = 2007;
Employee Fred;
make_employee(test_name, test_birth, test_start) = &Fred; <-- throws invalid lvalue error
return 0
}