/******************************************************************************
Welcome to GDB Online.
GDB online is an online compiler and debugger tool for C, C++, Python, PHP, Ruby,
C#, VB, Perl, Swift, Prolog, Javascript, Pascal, HTML, CSS, JS
Code, Compile, Run and Debug online from anywhere in world.
*******************************************************************************/
#include <stdio.h>
typedef struct node {
int x;
struct node* next;
} *Node;
void advance_node(Node ptr) {
if(!ptr) return;
ptr = ptr->next;
while (ptr) {
printf("%d\n", ptr->x);
ptr = ptr->next;
}
}
int main() {
Node node1 = malloc(sizeof (*node1));
Node node2 = malloc(sizeof (*node2));
Node node3 = malloc(sizeof (*node3));
node1->x = 1;
node1->next = node2;
node2->x = 4;
node2->next = node3;
node3->x = 9;
node3->next = NULL;
advance_node(node1);
return 0;
}