#include #include using namespace std; struct Node { int data; Node *next; }; void printNodes(Node *n) { while (n != NULL) { cout << n->data << endl; n = n->next; } } // add a node to the end of the list void addNode(Node *n, int i) { Node *prev; while (n != NULL) { prev = n; n = n->next; } n = new Node; prev->next = n; n->data = i; n->next = NULL; } int main() { Node *Head = new Node; Head->data = 0; Head->next = NULL; for(int x=0; x<10; x++) { addNode(Head, x); } printNodes(Head); return 0; }