Linked List

Run Settings
LanguageC
Language Version
Run Command
#include <stdio.h> #include <stdlib.h> struct link { int val; struct link* next; }; typedef struct link node; void display(node *start) { node *temp = start; while(temp!=NULL) { printf("%d-->",temp->val); temp=temp->next; } printf("NULL\n"); } node *create_new_node(int val) { node *result = malloc(sizeof(node)); result->val=val; result->next=NULL; return result; } node *insert_at_head(node *head, node *node_to_insert) { node_to_insert->next=head; return node_to_insert; } int main() { node *head=NULL, *temp; for(int i=3; i>0; i--) { temp = create_new_node(i); head = insert_at_head(head, temp); } //link them up display(head); return 0; }
Editor Settings
Theme
Key bindings
Full width
Lines