Skip to content
Snippets Groups Projects
Commit acbd5bf3 authored by Alec's avatar Alec
Browse files

fonction pour print l'entièreté des entrées

parent a2f20cc3
No related branches found
No related tags found
No related merge requests found
...@@ -329,6 +329,25 @@ void bp_destroy(node *root) { ...@@ -329,6 +329,25 @@ void bp_destroy(node *root) {
// PRINTING ---------------------------------------------------------- // PRINTING ----------------------------------------------------------
void bp_print_everything(node *tree) { // if we reached the end of the list
if (tree == NULL)
return;
// search for the first leaf on the tree
if (!bp_is_leaf(tree)) {
return bp_print_everything(tree->childs[0]);
}
// print every values in the node until hitting 0, then we can get on the
// next node
for (int i = 0; i < M; i++) {
bp_print_entry(tree->user[i]);
printf("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n");
if (tree->data[i + 1] == 0) {
return bp_print_everything(tree->next);
}
}
}
void print_date(date item) { void print_date(date item) {
printf("%d - ", item.day); printf("%d - ", item.day);
......
...@@ -39,6 +39,8 @@ void bp_print(node *root, int depth); ...@@ -39,6 +39,8 @@ void bp_print(node *root, int depth);
void bp_print_entry(entry person); void bp_print_entry(entry person);
void bp_print_everything(node *tree);
void bp_search(node *tree, char phone[11]); void bp_search(node *tree, char phone[11]);
/** /**
......
...@@ -44,8 +44,9 @@ int main() { ...@@ -44,8 +44,9 @@ int main() {
char phone_search[11] = {"0795787730"}; char phone_search[11] = {"0795787730"};
bp_print(tree, 0); bp_print(tree, 0);
printf("\n|||||||||\n"); printf("\n|||||||||\n");
printf("Recherche par n° de téléphone : \n");
bp_print_everything(tree);
printf("\nRecherche par n° de téléphone : \n");
bp_search(tree, phone_search); bp_search(tree, phone_search);
/* /*
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment