循环出现问题

来源:百度知道 编辑:UC知道 时间:2024/06/04 11:24:42
typedef struct node
{
int num;
int rank;
int sum;
int chinese;
int math;
int english;
struct node *next;
}snode;
void main()
{
int x,i;
snode *p;
p=head->next;
printf("\nInput the number of student to search his/her exam informations:");
scanf("%d",&x);
for(i=1;i<=10;i++)
{
if(x==p->num)
{
printf("\nThe score of chinese: %d\n",p->chinese);
printf("\nThe score of math: %d\n",p->math);
printf("\nThe score of english: %d\n",p->english);
printf("\nThe score of aggregate: %d\n",p->sum);
printf("\nThe score of order: %d\n",p->rank);
}
p=p->next;
}
}
为什么程序到了提示输入x,之后就执行不下去了呢?
就是不往下执

我来说一下,

1.你的程序里没有链表,就是说没数据,怎么访问

2.snode *p; 这应该是node *; 定义结构体指针

3.typedef struct node
{
int num;
int rank;
int sum;
int chinese;
int math;
int english;
struct node *next;
}snode;
这只是定义了一个自定义类型的结构体变量

4.头指针未定义

代码不全,最好再把链表看看

执行不下去是什么意思?

这个问题我不会,但是我用VC6。0++都 编译不过去。
int x,i;
snode *p;
p=head->next;//好像是这里有问题,head没定义
printf("\nInput the number of student to search his/her exam informations:");
scanf("%d",&x);
for(i=1;i<=10;i++)