error C2275:'STU' :illegal use of this type as an expression
来源:学生作业帮 编辑:神马作文网作业帮 分类:综合作业 时间:2024/11/11 01:18:15
error C2275:'STU' :illegal use of this type as an expression see declarat问题处在哪里?
代码如下,问题好像是insert()函数里面的STU定义问题,对这几个函数一个一个调试,第一个createlist()没问题(那些注释你懂得,我就不多解释了),
#include
#include
typedef struct student
{
\x05int num;
\x05char name[10];
\x05struct student *next;
}STU;
void createlist(STU *q)
{
\x05int i,n;
\x05STU *p;
\x05scanf("%d",&n);
\x05for(i=0;inext==NULL)
\x05\x05{
\x05\x05\x05scanf("%d %s",&p->num,p->name);
\x05\x05\x05q->next=p;
\x05\x05\x05q=p;
\x05\x05}
\x05\x05q->next=NULL;
\x05}
}
void insert(STU *p)
{
\x05int n;
\x05scanf("%d",&n);
\x05STU *q,*r;
\x05r=(STU *)malloc(sizeof(STU));
\x05while(p->num!=n)
\x05{
\x05\x05q=p;
\x05\x05p=p->next;
\x05}
\x05scanf("%d %s",&r->num,r->name);
\x05q->next=r;
\x05r->next=p;
}
/*
void findlist(STU *p)
{
\x05int n;
\x05scanf("%d",&n);
\x05while(p->num!=n)
\x05{
\x05\x05p=p->next;
\x05}
\x05printf("num:%d name:%s",p->num,p->name);
}
void printlist(STU *p)
{
\x05p=p->next;
\x05while(p->next!=NULL)
\x05{
\x05\x05printf("num:%d name:%s\n",p->num,p->name);
\x05\x05p=p->next;
\x05}
}
void dellist(STU *p)
{
\x05int n;
\x05STU *q;
\x05scanf("%d",n);
\x05while(p->num!=n)
\x05{
\x05\x05p=p->next;
\x05\x05q=p;
\x05}
\x05q->next=p->next;
\x05free(p);
}
*/
void main()
{
//\x05int n;
\x05STU head;
\x05head.next=NULL;
\x05createlist(&head);
\x05printf("OK1!\n");
\x05
\x05insert(&head);
\x05printf("OK2!\n");
/*\x05scanf("%d",n);
\x05switch(n)
\x05{
\x05case 1:createlist(&head);break;
\x05case 2:insert(&head);break;
\x05case 3:findlist(&head);break;
\x05case 4:printlist(&head);break;
\x05case 5:dellist(&head);break;
\x05case 0:exit();break;
\x05default:printf("输入错误!\n");
\x05}*/
}
代码如下,问题好像是insert()函数里面的STU定义问题,对这几个函数一个一个调试,第一个createlist()没问题(那些注释你懂得,我就不多解释了),
#include
#include
typedef struct student
{
\x05int num;
\x05char name[10];
\x05struct student *next;
}STU;
void createlist(STU *q)
{
\x05int i,n;
\x05STU *p;
\x05scanf("%d",&n);
\x05for(i=0;inext==NULL)
\x05\x05{
\x05\x05\x05scanf("%d %s",&p->num,p->name);
\x05\x05\x05q->next=p;
\x05\x05\x05q=p;
\x05\x05}
\x05\x05q->next=NULL;
\x05}
}
void insert(STU *p)
{
\x05int n;
\x05scanf("%d",&n);
\x05STU *q,*r;
\x05r=(STU *)malloc(sizeof(STU));
\x05while(p->num!=n)
\x05{
\x05\x05q=p;
\x05\x05p=p->next;
\x05}
\x05scanf("%d %s",&r->num,r->name);
\x05q->next=r;
\x05r->next=p;
}
/*
void findlist(STU *p)
{
\x05int n;
\x05scanf("%d",&n);
\x05while(p->num!=n)
\x05{
\x05\x05p=p->next;
\x05}
\x05printf("num:%d name:%s",p->num,p->name);
}
void printlist(STU *p)
{
\x05p=p->next;
\x05while(p->next!=NULL)
\x05{
\x05\x05printf("num:%d name:%s\n",p->num,p->name);
\x05\x05p=p->next;
\x05}
}
void dellist(STU *p)
{
\x05int n;
\x05STU *q;
\x05scanf("%d",n);
\x05while(p->num!=n)
\x05{
\x05\x05p=p->next;
\x05\x05q=p;
\x05}
\x05q->next=p->next;
\x05free(p);
}
*/
void main()
{
//\x05int n;
\x05STU head;
\x05head.next=NULL;
\x05createlist(&head);
\x05printf("OK1!\n");
\x05
\x05insert(&head);
\x05printf("OK2!\n");
/*\x05scanf("%d",n);
\x05switch(n)
\x05{
\x05case 1:createlist(&head);break;
\x05case 2:insert(&head);break;
\x05case 3:findlist(&head);break;
\x05case 4:printlist(&head);break;
\x05case 5:dellist(&head);break;
\x05case 0:exit();break;
\x05default:printf("输入错误!\n");
\x05}*/
}
vc6.0编译通过……
没有问题
再问: 可我的VC6.0就不行了啊,你执行了么?我带着这个代码用学校的VC6.0也不行!我再看看吧,谢谢你!
再答: 能执行
没有问题
再问: 可我的VC6.0就不行了啊,你执行了么?我带着这个代码用学校的VC6.0也不行!我再看看吧,谢谢你!
再答: 能执行
error C2275:'STU' :illegal use of this type as an expression
运行后说error C2275:'list' :illegal use of this type as an expre
报错c(179) :error C2275:'LNODE' :illegal use of this type as a
illegal use of this type as an expression是什么意思?
illegal use of this type as an expression
c语言错误:'FILE' :illegal use of this type as an expression这是神马情
程序为何会显示 illegal use of type 'void'
illegal start of expression是什么意思
Use the properties of logarithms to expand the expression as
error C2027:use of undefined type 'A' see declaration of 'A
Perhaps this book will prove to be of use to you in your stu
英语翻译An artificial relationship of this type would provide ma