Singly linked list Initialization:
Generating a new node makes a head node pointer L points to the head with the head node;
The head node pointer field blanking.
which is:
// single chain initialize the Status InitList_L (LinkList & L) { L = new new LNode; // C ++ syntax // L = (LinkList) the malloc (the sizeof (LNode)); // C syntax, malloc returns a pointer type, and needs a cast, in this case (LinkList) L-> Next = NULL; return the OK; // if successful, returns 1 }
main () function:
int main () { LinkList L; printf("%d\n", InitList_L(L)); return 0; }
result: