插入链表的问题。
16 //头节点17 PLIST pgst_head = NULL;
18 //链表长度
19 int n_size = 0;
20
21 //插入节点
22 int insert_node(STUDENT para_stu)
23 {
24 PLIST pst_temp = NULL;
25 PLIST tmp = NULL;
26
27 //申请空间
28 pst_temp = (PLIST)malloc(sizeof(LIST));
29 tmp = (PLIST)malloc(sizeof(LIST));
30
31 //判断是否申请成功
32 if (pst_temp == NULL)
33 {
34 return 8;
35 }
36
37 //赋值
38 strcpy(pst_temp->stu.name, para_stu.name);
39 strcpy(pst_temp->stu.no, para_stu.no);
40 pst_temp->stu.elec = para_stu.elec;
41 pst_temp->stu.expe = para_stu.expe;
42 pst_temp->stu.requ = para_stu.requ;
43 pst_temp->stu.sum = para_stu.elec + para_stu.expe + para_stu.requ;
44
45 pst_temp->pst_next = NULL;
46
47 //插入链表
48 //空链表的情况
49 if (pgst_head == NULL)
50 {
51 pgst_head = pst_temp;
52 tmp = pgst_head;
53 n_size++;
54 }
55 //链表不为空的情况
56 else
57 {
58 pst_temp->pst_next = tmp->pst_next;
59 tmp->pst_next = pst_temp;
60 n_size++;
61 }
62
63 return 0;
64 }
只能插入一个头结点,然后就插不进去了。