//Input a list of names and year born from file #include #include #include using namespace std; int readfile(string names[],int years[],int max) { int count=0; ifstream namefile; //input file stream namefile.open("c:/mycpp/names2.txt"); //associates the name with a file if (namefile.fail()) //maybe no disk in external file, or the file does not exist cout<<"File not found\n"; //cout is used to notify user of error else { while(!namefile.eof() && count>names[count]; namefile>>years[count]; count++; } //while } //file ok return count; }//readfile int bsearch(string names[], string name, int size) { int min=0; int max=size-1; int pos; int found=-1; while(min<=max && found==-1) { pos=(min+max)/2; //midpoint of the range if(name==names[pos]) found=pos; else if(name=0) cout<