Ejemplo n.º 1
0
int main(void)
{
    Tree pets;
    char choice;

    InitializeTree(&pets);
    while ((choice = menu()) != 'q')
    {
        switch (choice)
        {
            case 'a' :  addpet(&pets);
                        break;
            case 'l' :  showpets(&pets);
                        break;
            case 'f' :  findpet(&pets);
                        break;
            case 'n' :  printf("%d pets in club\n",
                                TreeItemCount(&pets));
                        break;
            case 'd' :  droppet(&pets);
                        break;
            default  :  puts("Switching error");
        }
    }
    DeleteAll(&pets);
    puts("Bye.");
   
    return 0;
}
Ejemplo n.º 2
0
int main(void) {
	Tree pets;
	char choice;
	InitializeTree(&pets);

	while ((choice = menu()) != 'q') {
		puts("");
		if (choice == 'a') {
			addpet(&pets);
		} else if (choice == 'l') {
			showpets(&pets);
		} else if (choice == 'f') {
			findpet(&pets);
		} else if (choice == 'n') {
			printf("%d pets in club\n", TreeItemCount(pets));
		} else if (choice == 'd') {
			droppet(&pets);
		} else {
			printf("Not a valid option.\n");
		}
		puts("");
	}
	DeleteAll(&pets);
	puts("Bye.");

	return 0;
}