/******************************************************* * Author: Dave Schoeffler * * This program will utilize my own binary tree library * * It will allow the user to create their own tree by * * choosing from a menu what operation they would like * * to perform. * * * * Compile with: gcc -o tree tree.c -ltree -L. * * * * Execute with: ./tree * * * *******************************************************/ #include "tree.h" int main() { //aTree will be used to store the character values Tree *aTree; aTree = malloc(sizeof(Tree *)); char input, choice, junk; //this menu allows the user to choose what operation they would like to perfor printf("Enter - 1 - to add a Node to the tree\n"); printf("Enter - 2 - to display the contents of the tree in ascending order\n") printf("Enter - q - to quit\n"); scanf("%c",&choice); scanf("%c",&junk); while( choice != 'q') { switch(choice) { //if they enter 1 they will be asked what character they would like to a case '1': printf("Please enter the character you would like to add to the tree: scanf("%c",&input); scanf("%c",&junk); aTree = insert(aTree, input); break; case '2'://if they choose 2 the tree will be displayed in lexicographica printf("The following values are contained in this binary tree: "); display(aTree -> root); printf("\n"); break; case 'q': case 'Q': break; default: printf("Invalid input!\n"); break; } printf("Enter - 1 - to add a Node to the tree\n"); printf("Enter - 2 - to display the contents of the tree in ascending order\ printf("Enter - q - to quit\n"); scanf("%c",&choice); scanf("%c",&junk); } printf("The following values are contained in this binary tree: "); display(aTree -> root);// once they choose to quit the tree will be displayed printf("\n"); return (0); }