I have this code:
typedef struct node* AVLNode;
struct node
{
char Word[50];
AVLNode Left;
AVLNode Right;
};
void Insert(char* S, AVLNode T)
{
if( T == NULL )
{
T = malloc( sizeof( struct node ) );
if( T == NULL )
printf( "Out of space!!!" );
else
{
strcpy(T->Word, S);
T->Left = T->Right = NULL;
}
}
}
int main(){
AVLNode tree = NULL;
Insert("SRING!!!", tree);
printf(tree->Word);
}
In Insert("SRING!!!", tree);
I give it a pointer to the node (AVLNode type), it should find that it printf(tree->Word); equals null and give it a size (malloc) and copy string to T->Word, but printf(tree->Word);
prints nothing, why is that and how can I solve it?
Thanks