Please can you help with my lniked list I've got a node declared and passed to function
append_nodes wihtin main, Then in that function I input the elements for the node and assign the
next pointer to a new node and test for memory.
I'm not sure where to put my while loop to build new nodes and to include there input and test for memory
I know where it is now is not possible I've only included it to show what I think I need in my loop.
node *top=new node;
void append_nodes(struct node *append)
cout<<"Enter persons name >";
cout<<'\n'<<"Enter persons age >";
thanks for the help.
It's / NOT \ in the tags!
First step is separate the 'data input' from the 'append list' function.
Your code in main() should look like
Hopefully, you'll end up with 3 small functions which you can test separately, rather than some 'big bang' function which does everything.
node = create_node();
fill_in_data(node); // this reads from the user
list = append_list( list, node ); // appends node to list, and returns a (modified) list
Note, the list is only really modified when appending a node to an empty list.