Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and medical aesthetics - Can the linked list in the data structure store different types of data, such as int type and char type, or can it only store the same type of elements?
Can the linked list in the data structure store different types of data, such as int type and char type, or can it only store the same type of elements?
It depends on what kind of watch you build. If your typedef is an integer table, you can only put plastic data and double floating points, but if you define it with a structure, it is ok to include different types. For example, if you want to build a linked list of students' names and grades, you can do so.

Typedef structure data {

int num

char name[20];

Floating score [m];

} data; //Define the student data structure

Typedef structure stu{

Data students;

struct stu * next

}stu, * LinkList// defines the head node of the linked list.

Then establish a linked list of this structure.

l =(LinkList)malloc(sizeof(stu));

If (! l)

Returns 0; //Exception handling

l-& gt; Next = NULL// Create a single linked list with leading nodes.

Then enter the student data function, so that you can enter different types of data at the same time.

I didn't call. I don't know if I understand ... I feel messy. .............