struct TreeNode {
int item; // The data in this node.
TreeNode *left; // Pointer to the left subtree.
TreeNode *right; // Pointer to the right subtree.
};
int main (void){
TreeNode myTree;
myTree.item = 1;
myTree.left->item = 2;
myTree.right->item = 3; //it starts crashing here.
myTree.left->left->item = 4;
myTree.left->right->item = 5;
myTree.right->left->item = 6;
myTree.right->right->item = 7;
return 0;
}
it compiles fine, and i think the syntax is fine. but it crashes when i run it. i removed the lines starting at item = 3, and it will run fine.