I'm trying to write a binary tree with this as a tree:
QUOTE
struct node{
char val;
node *left;
node *right;
};
My variables are:
QUOTE
node *tree = new node;
node *root = new node;
root = NULL;
tree = NULL;
string equation;
equation is suppose to hold a simple equation like A+B
I want to read the equation into the node, like this:
QUOTE
root->left->val = equation[2]
root->val = equation[1]
root->right->val = equation[3]
So the tree will have + as the parent, and A and B as the children.
There aren't any compilation errors, but when I run the program, it crashes, and I did some cout statements, and found out there was an error setting the root->val stuff.
I've written a linklist with nodes where val was an integer, and it never crashed. why is it crashing when I try to set the value as a char?
This post has been edited by ach: 19 May, 2008 - 11:08 AM