关于链表的问题
# include <stdio.h># include <string.h>
struct Student
{
char name[10];
double score;
Student * next;
};
int main(void)
{
Student stu1, stu2, stu3, * head, *q;
strcpy(stu1.name, "Wang");
strcpy(stu2.name, "Guo");
strcpy(stu3.name, "Mo");
stu1.score=66.6, stu2.score=33.3, stu3.score=98.9;
head=&stu1, stu1.next=&stu2, stu2.next=&stu3, stu3.next=NULL;
q=head;
for (;q!=NULL;q=q->next)//如果这里没有“q!=NULL”会怎样?
printf("%s's score is %.2lf.\n", q->name, q->score);
printf("\n");
return 0;
}