Implementation of linked list in C

来源:互联网 发布:java bufferstring 编辑:程序博客网 时间:2024/05/19 21:42

There is a caveat here, which requires us to use a double pointer for the head, otherwise, we will only update the local copy of head.

bool insertInFront(IntElement **head, int data){    IntElement *newElem = malloc(sizeof(IntElement));    if(!newElem) return false;    newElem->data = data:    newElem->next = *head;    *head = newElem;    return true;}