Professional Documents
Culture Documents
Declaration:: Typedef
Declaration:: Typedef
:
struct node {
int val;
struct node* LChild;
struct node* RChild;
};
typedef struct node* Tree;
initialization:
T = NULL;
Display the nodes of a certain condition and save them in a binary file
at the same time
void displayandsave (BST T, char filename [])
{
FILE* f=NULL;
f = fopen(filename, "a+b");
if (T==NULL) return;
else {
printf("Paquet with id %d and source %s and destination %s.\n", T-
>p.id, T->p.source, T->p.destination);
fwrite(&(T->p), sizeof(paquet),1, f);
displayandsave(T->LChild, filename);
displayandsave(T->RChild, filename);}
fclose(f);
}