A stupid question maybe, but I am having trouble creating a NULL tree:
#include <stdlib.h>
#include <stdio.h>
struct node {char *data; struct node *left; struct node
*right;} ;
typedef struct node tree ;
void create();
int empty();
main(){
tree t ;
create(&t);
if(empty(&t)){
printf("TREE is empty \n");}
}
void create(tree *t ){/*creates an empty tree */
t =NULL;}
int empty( tree *t ){/* returns 1 if empty*/
return (t ==NULL ? 1 : 0);}
This compiles and runs, but does not print that tree is empty
What am I doing wrong here?
Thanks, svar
#include <stdlib.h>
#include <stdio.h>
struct node {char *data; struct node *left; struct node
*right;} ;
typedef struct node tree ;
void create();
int empty();
main(){
tree t ;
create(&t);
if(empty(&t)){
printf("TREE is empty \n");}
}
void create(tree *t ){/*creates an empty tree */
t =NULL;}
int empty( tree *t ){/* returns 1 if empty*/
return (t ==NULL ? 1 : 0);}
This compiles and runs, but does not print that tree is empty
What am I doing wrong here?
Thanks, svar