Skip to content

Instantly share code, notes, and snippets.

@fabianbaechli
Created April 22, 2025 14:00
Show Gist options
  • Select an option

  • Save fabianbaechli/3eecb05f19b3c62ea42f0c77cd58d678 to your computer and use it in GitHub Desktop.

Select an option

Save fabianbaechli/3eecb05f19b3c62ea42f0c77cd58d678 to your computer and use it in GitHub Desktop.
struct Node {
int val;
struct node* next;
};
struct Node* newNode(int val) {
struct Node* p = malloc(sizeof(struct Node));
p->val = val;
return p;
}
int main() {
struct Node* root = newNode(0);
struct Node* p = root;
for(int i = 1; i < 10; i++) {
p -> p = newNode(i);
p = p -> next;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment