#include<iostream>
#include<stdio.h>
#include<stdlib.h>
usingnamespace std;
int main()
{
int choice;
while(1)
{
fflush(stdin);
choice = 0;
printf("\nError Demonstration");
printf("\n Main Menu");
printf("\n\n 1. Insert a new node");
printf("\n 2. Display the current tree using recursion");
printf("\n 3. Display the current tree using stack");
printf("\n 4. Exit");
printf("\n\n Kindly enter the number associated with the choice..");
cin>>choice;
printf("\nYou entered %d", choice);
switch(choice)
{
case 0: printf("\n\nI guess something went wrong with how I clear the input stream!");
printf("\n\nPulling rip-cord and bailing out! ");
exit(1);
break;
case 1: printf("You Choose to insert a new node");
break;
case 2: printf("You Choose to display the tree\n\n");
break;
case 3: printf("You Choose to display the tree with stack\n\n");
break;
case 4: printf("You Choose to exit\n\n");
exit(1);
default: break;
}
}
return 0;
}
Xander 314 you havn't tried to code i think sir, this actually (your solution) is what i thought first but it prints all those lines under main menu... back and this solution does not solve the problem... thanks anyway you all