链表头使用结构体:struct Class
链表中的每一项使用结构体:struct Student
#include <stdio.h>
struct Student {
char * StudentName;
int StudentAge;
int StudentSex;
struct Student * NextStudent;
};
struct Class {
char *ClassName;
struct Student * NextStudent;
};
int main(void)
{
printf("Hello World!\r\n");
struct Class Class_A;
Class_A.ClassName = "A";
Class_A.NextStudent = NULL;
struct Student Student_1;
Student_1.StudentName = "PENG";
Student_1.StudentAge = 18;
Student_1.StudentSex = 1;
Student_1.NextStudent = NULL;
Class_A.NextStudent = &Student_1;
printf("The name of the first student %s\r\n", Class_A.NextStudent->StudentName);
return 0;
}
![在这里插入图片描述](https://i-blog.csdnimg.cn/blog_migrate/6d6cc2d5eea8674f4f4f7968a2a4dda2.png)