Skip to content

Instantly share code, notes, and snippets.

@izmajlowiczl
Created August 31, 2017 09:53
Show Gist options
  • Save izmajlowiczl/51ca32877c93e851035f2d2c9351b00a to your computer and use it in GitHub Desktop.
Save izmajlowiczl/51ca32877c93e851035f2d2c9351b00a to your computer and use it in GitHub Desktop.
struct node {
int value;
struct node *next;
};
void push_front(struct node* root, int value) {
struct node* new_root = create_node(value);
if (!new_root) ERR("Cannot allocate memory for node to add/n");
new_root->next = root;
root = new_root;
}
int main(void) {
struct node root;
root.value = 1;
root.next = NULL;
push_front(&root, 10);
traverse(&root);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment