MCPcopy Create free account
hub / github.com/AdvancedCompiler/AdvancedCompiler / initLink

Function initLink

code/Chapter8/8-23.c:31–42  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

29 struct ListNode* next;
30}Node, * PNode;
31Node* initLink() {
32 Node* p = (Node*)malloc(sizeof(Node));//创建一个头结点
33 Node* temp = p;//声明一个指针指向头结点,用于遍历链表
34 for (int i = 1; i < 10; i++) {
35 Node* a = (Node*)malloc(sizeof(Node));
36 a->Element = i;
37 a->next = NULL;
38 temp->next = a;
39 temp = temp->next;
40 }
41 return p;
42}
43void display(Node* p) {
44 Node* temp = p;//将temp指针重新指向头结点
45 while (temp->next) {

Callers 1

mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected