注册 登录
编程论坛 新人交流区

程序编译出问题了,请指点

sugar123 发布于 2007-10-06 02:47, 241 次点击
编译时出问题,

#include<iostream.h>
struct student
{
long num;float score;
struct student *next;
;
int k=0;
struct student *creat()
{
struct student *head,*p1,*p2;
head=NULL;
p1=new(student);
p2=p1;
cin>>p1->num>>p1->score;
while(k<=5)
{
n++;
if(k==1)
head=p1;
else
p2->next=p1;
p2=p1;
p1=new(student);
cin>>p1->num>>p1->score;
}
delete(p1);
p2->next=NULL;
reture(head);
}

Compiling...
044.cpp
e:\visualc++\install\msdev98\myprojects\04\044.cpp(7) : error C2252: 'k' : pure specifier can only be specified for functions
e:\visualc++\install\msdev98\myprojects\04\044.cpp(30) : fatal error C1004: unexpected end of file found
执行 cl.exe 时出错.

044.obj - 1 error(s), 0 warning(s)
2 回复
#2
liaozb2007-10-06 12:13

while(k<=5)
{
n++;
...
}
改:k++

#3
bobofei2007-10-06 13:52
细心看看程序,才发现,原来我什么都不懂!!@
1