Hi everybody, I would need and advice. I work with binary tree in language C and I wanna to save data from binary tree to file. I try to make similar way to C++, but proposed code notice failure. How I modify it to put it into operation. that's the part of code with highlighted critical section: (thx for your reply)
void WriteToFile(char* file_name,ITEMTREE** binary_tree)
{
FILE* file;
if(fopen_s(&file,file_name,"w")!=0)
{
puts("failure\n");
}
else
{
WriteNodes(file,binary_tree);
fclose(file);
}
}
void WriteNodes(FILE* file,ITEMTREE** binary_tree)
{
if(binary_tree != NULL)
{
WriteNodes(**file**,&(*binary_tree)->left);
fprintf(file,"%s %d\n",(*binary_tree)->surname,(*binary_tree)->ID_student);
WriteNodes(file,&(*binary_tree)->right);
}
}