// I can see why functions delete_nodes and input_data have pointers as there argumens
// because they are passed the address of top_ptr ok thats fine.
// Now top_ptr is declared as a pointer to type node which is fine but then in the line
// top_ptr = create_nodes(); this calls the function create_nodes which returns the
// address of top and assigns it to the address of top_ptr should'nt the said line be
// *top_ptr = create_nodes(); (assign the address returned to a pointer).
// But if I change the top line in main to node *top_ptr = create_nodes();
// and therefore not needing the second line everything is fine
// therefore my problem in the above paragraph must be due to something
// about it pointing to NULL but what.
// Thanks all for taking the time to help me.Code:#include<iostream.h> #include<conio.h> #include<stdlib.h> #define MAX 30 // function returns a pointer to a structure of type node struct node * create_node(); // why do I need the struct keyword here void delete_nodes(node *start_ptr); void input_data(node *node); struct node{ int age; char name[MAX]; node *next; }; int main() { node *top_ptr=NULL; top_ptr=create_node(); input_data(top_ptr); delete_nodes(top_ptr); return 0; } node * create_node() { node *top=new node; if(top==NULL) abort(); top->next=NULL; return top; } void input_data(node *node) { cout<<"Input name->"; cin>>node->name; cout<<'\n'<<"Input age->"; cin>>node->age; } void delete_nodes(node *start_ptr) { node *hold; while(start_ptr!=NULL) { hold=start_ptr; start_ptr=start_ptr->next; cout << "Memory freed for '" << hold->name << "'" << endl; delete(hold); } }