有誰見過這個錯誤,怎麼解決呢???
error C2037: “tel”的左側部分指定未定義的結構/聯合“contact”
struct contact
{
char name[20];
char sex;
int age;
char tel[11];
char add[200];
};
struct contact* insert(struct contact *x)
{
x = (struct contact *)malloc(sizeof(contact));
printf("Please Enter The Name:\n");
gets(x->name);
printf("Please Enter The Tel:\n");
gets(x->tel);
printf("Please Enter The Add:\n");
gets(x->add);
printf("Please Enter The Sex:\n");
scanf("%c",&x->sex);
printf("Please Enter The Age:\n"); //調整了輸入是為了輸入數據完整,或者你全部使用 gets 來獲取數據。。
scanf("%d",&x->age);
return x;
}
int main()
{
struct contact *x = {0};
insert(x);
system("pause");
return 0;
}
結構體記得提前聲明。。。