if anyone has time to help me....i am missing something that i cannot see. the value of x is supposed to be transferring to p->info but it does not. i cant figure out why. because of this, the expression cannot be evaluated and the recursive function cycles infinitely forcing the program to crash. i have tried everything i can think of over the past 5 days and i am out of ideas.
i followed the instructor's demonstration as best i could, but apparently i missed something. if anyone can see what i am doing wrong here, i would greatly appreciate the help.
Code:#include <iostream> #include <cstring> // the node.info was previously a string variable, changed to INT till i figure this out using namespace std; struct node { int info; node *left; node *right; }; node *root; root=new(node); root=NULL; void insert(node *&p, int x); // prototype void main() { int month; for(int i=1; i<=7; i++) { cout<<"Enter a value: "; cin>>month; insert(node *&root, month); } } //end MAIN void insert(node *&p, int x) { if (p==NULL) { p=new(node); p->info=x; p->left=NULL; // debugger always halts here p->right=NULL; }; else if(x < p->info) insert(p->left, x); else insert(p->right, x); }