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 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97
|
int main()
try{
char m;
char l;
char choice;
string name; //name of file
vector<string>names; //vector for names
vector<char>initials; //vector for initials
vector<int>chosen; //vector for names with initials
cout <<"Sooo, I'm going to need you to write the name of the file "
<<"where you keep your names (include the .txt-- Like Names.txt "
<< "or something).\n"<<endl;
cin >> name;
cout << string(3,'\n');
get_names(names,name);
get_initials(names,initials);
do{
cout <<"OK, sooo what names do you want me to get for you? " << endl;
cout <<"Names that begin with the letteeeer: ";
cin >> l;
//l=toupper(l);
cout << string(2,'\n');
get_chosen(initials,chosen,l);
cout <<"Do you want them: "<<endl;
cout <<"1)One by one" <<endl;
cout <<"2)All together\n" <<endl;
cin >> choice;
cout << string(2,'\n');
switch(choice)
{
case '1':
if(chosen.size()==0){cout << "No names with that letter ." <<endl;}
else
cout <<"Juust keep pressing enter until you reach the end\n" <<endl;
for(int i=0; i<chosen.size();i++)
{
cin.ignore();
cout << names[chosen[i]];
}
cout << string(3,'\n');
break;
case '2':
if(chosen.size()==0){cout << "No names with that letter." <<endl;}
else
cout << "Here you go!\n" << endl;
for(int i=0; i< chosen.size();++i){cout << names[chosen[i]] << string(1,'\n');}
cout << string(3,'\n');
break;
default:
cout <<"thaaat's not a choice" <<endl;
break;
}
cout <<"Do you want to look for another namee ooor "
<<"did you find what you were looking for?" <<endl;
cout <<"y to repeat, anything else to end. " <<endl;
cin >>m;
if( m != 'y' && m !='Y')
{
string mesh;
cout <<"\nOkidoky, this is it.\nGlad this program could help!. Later! "<<endl;
cout <<"Soooo, now press anything to quiiit" <<endl;
cin >> mesh;
}
}while(m =='y' || m =='Y');
}
catch(int i)
{
if(i==1) {cout <<"Emm..., problem. Did you type the name right? if yes...\n"
<<"Check the file in the folder. Type anything: "; string x; cin>> x; cout << endl;}
}
|