Jamestf347
Well I've been working on this phone book sort of c++ program for my high school class, It incorporates everything we've learned so far ... The only problem is I never got a hand of searching before we went by it. So with that said, Can anyone help me fix my search method? I don't see a problem in it, but then again I said I don't fully get search. Thank you for Who Ever Helps me, I'll make it worth your while
.
** IGNORE SOME OF THE VARIABLES USED, THEY MIGHT IN FACT BE GLOBAL, JUST NOT SHOWN HERE.
Once again I say thank you for anyone willing to help.
| Code: |
|
void searchbyname() { if (retrieved==1) { int i, flag1, flag2, searchammount; char searchname1[30], searchname2[30], found, found2; clrscr(); cout<<"Compiling Data..."; delay(700); clrscr(); cout<<"Searching By Name..."; delay(700); clrscr(); do { clrscr(); cout<<"Please Enter The First Name To Search For: "; cin>>searchname1; //first name temporary search variable clrscr(); cout<<"Please Enter The Last Name To Search For: "; cin>>searchname2; //last name temporary search variable flag1=1; flag2=1; for (i=1; i<=num; i++) { found=stricmp(firstname[i], searchname1[1]); // Comparing The first names in file with the first name to be searched found2=stricmp(lastname[i], searchname2[1]); // Comparing The last names in file with the last name to be searched if (found == 0) { clrscr(); cout<<"\n"<<searchname1<<" In Slot number "<<i; // firstname found getch(); flag1=0; } if (found2 == 0) { clrscr(); cout<<"\n"<<searchname2<<" In Slot number "<<i; //lastname found getch(); flag2=0; } } else if (flag1 == 0 && flag2 == 0) //not found if statement { clrscr(); cout<<searchname1[1]<<" "<<searchname2[1]<<" Not Found"; gotoxy(50, 18); cout<<"Press Enter To Continue!"; getch(); } clrscr(); cout<<"Would You Like To Search For Anymore Names? (y/n): "; cin>>choice1; } while (choice1 == 'y' || choice1 == 'Y'); } if (retrieved == 0) { clrscr(); cout<<"PLEASE RETRIEVE DATA BEFORE USING THIS OPTION!"; getch(); mainmenu(); } } |
** IGNORE SOME OF THE VARIABLES USED, THEY MIGHT IN FACT BE GLOBAL, JUST NOT SHOWN HERE.
Once again I say thank you for anyone willing to help.
