C语言链表最简单实现(结构体过渡到链表)

#include<stdio.h>
/*
01 构建链表
02 初始化链表  注意头节点 直接赋值
03 输出链表 

*/

struct stu{
	int num;
	float score;
	struct stu *next;
};

int main(){


struct stu a, b, c, *head;
a.num =1;
a.score = 89;

b.num = 2 ;
b.score = 98;

c.num = 3;
c.score = 99;

head = &a;
a.next = &b;
b.next = &c;
c.next = NULL;

do{
	printf("student number: %d score:%f\n",head->num, head->score);
           head =	head->next; //head->next = head
}while(head);

return 0;
} 

猜你喜欢

转载自blog.csdn.net/qq_39463175/article/details/115343792
今日推荐