the problm is when i entered the musolla function and chose on the option,the program wont return to main and ask the user wether they want to continue/not?Code:#include<stdio.h> void search (char[]); void calc(int ); void Musolla(); void GPCL(); void AcademicAffairs(); void ExamHall(); void OSCENT(); void DeanOffice(); int main() { char location[20]; char ans; do { printf("Enter your location: "); gets(location); search(location); printf("\nDo you want to continue?(Type 'y' for yes, or 'n' for no)\n"); printf("=>"); scanf(" %c", &ans); fflush(stdin); } while(ans == 'y'); system("pause"); return 0; } void search (char location[]) { char Places[6][20] = {"Academic Affairs", "GPCL", "Musolla", "Dean's Office", "Exam Hall", "OSCENT"}; int i, colour1; for(i=0;i<10;) { if(strcmp(location, Places[i]) == 0) { colour1= i; break; } else i++; if(i==10) { colour1 = -1; printf("Invalid location: %s\n",location); } } if(colour1 != -1) calc(colour1); } void calc(int colour1) { printf("\nChoose your destination\n1.Academic Affairs 2.GPCL 3.Musolla 4.Dean's Office 5.Exam Hall 6.OSCENT\n"); printf("=>"); int destin; scanf("%d",&destin); switch(destin) { case 1 : AcademicAffairs(); break; case 2 : GPCL(); break; case 3 : Musolla(); break; case 4 : DeanOffice(); break; case 5 : ExamHall(); break; case 6 : OSCENT(); break; } } void Musolla() { char path,ans; printf("Choose your path- a.Shortest b.Covered c.Handicapped\n "); scanf("%s", &path); switch (path) { case 'a': printf("amir\n");break; case 'b': printf("amir2\n");break; case 'c': printf("amir3\n");break; } } void GPCL() { printf("ass\n"); } void AcademicAffairs() { printf("baik\n"); } void DeanOffice() { printf("giler\n"); } void ExamHall() { printf("air\n"); } void OSCENT() { printf("ball\n"); }
when entering diff function,the program able to go back to main..
can someone detect the problem with my coding??