1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57
|
int main(){
//different variables to hold user response and file read and write
char filename[25]="rijal.txt",fileread[2000], cont='Y', naame[200];
ofstream writeFile;
ifstream readFile;
int count=0;
readFile.open(filename);
if(readFile.fail()){
cout<<"File does not exist!"<<endl;
cout<<"Please make sure you have put rijal.txt file and executable\n"
<<"file in one folder"<<endl; }
readFile.close();
readFile.open(filename);
readFile>>noskipws;
cout<<endl;
readFile.getline(fileread,'\n');
count=atoi(fileread);
//read in to struct variable info from file
for(int i=0;i<count;i++){//inplace of count put actual number of narrators
readFile.getline(narrator[i].name, 200);
readFile.getline(narrator[i].birth,100);
readFile.getline(narrator[i].death,100);
readFile.getline(narrator[i].narrated_from,2000);
readFile.getline(narrator[i].narrated_to,2000);
readFile.getline(narrator[i].level,100);
readFile.getline(narrator[i].known_for,200);
}
readFile.clear();
readFile.ignore();
readFile.close();
cout<<count<<endl;
while(cont=='Y'){
cout<<"Please enter full name to search for: ";
//cin.ignore();
cin.getline(naame, 200);
displayInfo(narrator, naame, count);}
return 0;
}
|