so these are my structures:
struct information
{
int Id;
char name[20];
}
that structure I use in my tree structure
struct node{
information *employee;
node *left,*right
}
and I have a generating function:
node* generate_tree_from_file(void)
{
node* tree=malloc(sizeof(node));
employee* emp=malloc(sizeof(employee));
int NoEmployees;
FILE *input_file;
input_file=fopen("emp.bin","r");
if(input_file)
{
fread(&NoEmployees,sizeof(int),1,input_file);
for(int i=0;i<NOEmployees;i++)
{
fread(&employee,sizeof(employee),1,input_file);
//Insert prototype: node* Insert(struct Employee*,struct node*)
//Insert @param: first param. is a pointer to a struct of type employee,second one is //the tree in which we want to insert
Insert(employee,tree);
}
fclose(fisier);
}
return tree;
and this is how I use it in my main function:
int main()
...
node* Tree;
Tree=generate_tree_from_file();
...
I don't understand why the value of Tree in main is NULL