I am getting “Unhandled exception at 0x00263ACB in Trees.exe: 0xC0000005: Access violation reading location 0x00000000.” on the first if statement of remove_node function. Can anyone give me a suggestion, I am stumped.
Thanks
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
It looks like the error could be hidden here:
In both cases you go to the left child and at some point approach a leaf (and try to delete its child which doesn’t exist). Try to replace one of
remove_node(num, node_ptr->left);byremove_node(num, node_ptr->right);Also it’s a good idea to first check whether a node exists.