【C语言】实现建立一个静态链表

将链表中的数据依此输出功能

#include 
#include 

struct student
{
	char num[20];
	float grades;
	struct student* next;
};

int main()
{
	struct student a, b, c, * head, * p;
	strcpy(a.num, "098207101");
	a.grades = 89.5;
	strcpy(b.num, "098207102");
	b.grades = 90;
	strcpy(c.num, "098207103");
	c.grades = 85;
	head = &a;
	a.next = &b;
	b.next = &c;
	c.next = NULL;
	p = head;
	while (p)
	{
		printf("%s %f\n", p->num, p->grades);
		p = p->next;
	}

	return 0;
}

你可能感兴趣的:(链表,c语言)