Data Structure help
I understand how to set up the list but how do I output values that I entered into the list? #include <iostream> using namespace std; struct node { int data; node *next;///pointer next to point to next node }; node *AddNode(node *plist) ///function takes list pointer { node *n=new node;///create new node cout<<"Enter value into node: "; cin>>n->data;///enter data value n->next=plist;///accessing next pointer to point to list plist=n;///list now holds the new node return plist; } int main() { node *plist; int num; cout<<"Enter how many nodes: "; cin>>num; for(int i=0; i<num; i++) { AddNode(plist); } cout<<"Output: "<<endl; for(int i=0; i<num; i++) { cout<<plist->data<<endl; } }