Hello to all..
I'm having a little problem with my program about linked list...when adding an element at the end of the list for a second time, a window that says that the visual c++ 6.0 had an error and needs to be close..i already thought lots of other ways to solve the problem but it just keeps happening again and again..
i'll be posting the code here:
Code:void FunctionAddData(int newData) { node *currentPointer = NULL; node *last = NULL; currentPointer = root; node *tempNode = new node; cout<<"Enter a number: "; cin>>tempNode -> data; tempNode -> next = NULL; if(tempNode == NULL) return; else { tempNode -> next = NULL; if(root == NULL) { root = tempNode; last = tempNode; } else { last -> next = tempNode; last = tempNode; } } main(); return; }




Reply With Quote