C语言一个程序运行报错,大神帮忙看一下
#include<stdio.h>intmain(){structstudentstudent1={1001,"liming"};//error:variablestud...
#include<stdio.h>
int main()
{
struct student student1={1001,"liming"}; //error:variable student student 1 has initializer but incomplete type
struct student *p;
p=&student1;
printf("number:%d\n",p->num);
printf("name:%s\n",p->name);
getch();
}
struct student{
int num;
char name[20];
}; 展开
int main()
{
struct student student1={1001,"liming"}; //error:variable student student 1 has initializer but incomplete type
struct student *p;
p=&student1;
printf("number:%d\n",p->num);
printf("name:%s\n",p->name);
getch();
}
struct student{
int num;
char name[20];
}; 展开
1个回答
推荐于2016-10-02 · 知道合伙人教育行家
关注
展开全部
#include<stdio.h>
struct student{//结构体放main函数前
int num;
char name[20];
};
int main()
{
struct student student1={1001,"liming"}; //error:variable student student 1 has initializer but incomplete type
struct student *p;
p=&student1;
printf("number:%d\n",p->num);
printf("name:%s\n",p->name);
getchar();
}
/*运行结果:
number:1001
name:liming
*/
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询