Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR C

add last in list c

void addLast(struct node **head, int val)
{
    //create a new node
    struct node *newNode = malloc(sizeof(struct node));
    newNode->data = val;
    newNode->next     = NULL;

    

    //if head is NULL, it is an empty list
    if(*head == NULL)
         *head = newNode;
    

}
Source by www.log2base2.com #
 
PREVIOUS NEXT
Tagged: #add #list
ADD COMMENT
Topic
Name
1+4 =