Code:#include <iostream> #include <conio> using namespace std; struct node{ int data; node *next; }; void add_node(node *list, int num); void output_list(node *list); int main(){ node *list = new node; node *first = list; //this pointer always points to the head node node *current = list; //current node...? list -> next = NULL; add_node(list, 1); add_node(list, 2); add_node(list, 3); //output_list(node* list); return 0; } void add_node(node *list, int num){ node *temp; temp -> data = num; temp -> next = list -> next; list -> next = temp; cout << list -> data << endl; getch(); } //end void add_node
I have tried everything and nothing works. How can I make three nodes, first off? This won't work