fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. struct Node {
  5. int data;
  6. Node* next;
  7. };
  8.  
  9. int main() {
  10. Node* head = new Node{10, NULL};
  11. head->next = new Node{20, NULL};
  12. head->next->next = new Node{30, NULL};
  13.  
  14. // print list
  15. Node* temp = head;
  16. while(temp != NULL) {
  17. cout << temp->data << " ";
  18. temp = temp->next;
  19. }
  20.  
  21. return 0;
  22. }
  23.  
Success #stdin #stdout 0.01s 5280KB
stdin
Standard input is empty
stdout
10 20 30