struct stud_node {
int num;
char name[20];
int score;
struct stud_node *next;
};
struct stud_node *head, *tail;
void input();
int main()
{
struct stud_node *p;
head = tail = NULL;
input();
for ( p = head; p != NULL; p = p->next )
printf("%d %s %d\n", p->num, p->name, p->score);
return 0;
}
/* 你的代码将被嵌在这里 */
scanf("%s %d", p->name, &p->score); //name是字符串数组,不需要加&
if(head)就是判断链表是否为空。
if中0为假,非0为真,head==NULL则说明是空链表