cbeginner
C Linked List Push Front
Dynamic memory allocation and pointer rebinding in C
By ApeType Staff·14 lines·295 characters·1,420 total attempts
#include <stdio.h>
#include <stdlib.h>
struct Node {
int value;
struct Node* next;
};
void push_front(struct Node** head, int val) {
struct Node* new_node = (struct Node*)malloc(sizeof(struct Node));
new_node->value = val;
new_node->next = *head;
*head = new_node;
}
TRANSCRIBE
Ready when you are.
Test your muscle memory and transcription speed against this exact snippet.
Start Typing
Tip: Press Esc anytime to restart
Best runs on this snippet
No recorded runs yet. Be the first to type this snippet!