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
|
#include <iostream>
#include <string>
#include <fstream>
using namespace std;
int main()
{
/*string phoneList[]={"Becky Warren, 678-1223",
"Joe Looney, 586-0097",
"Geri Palmer, 223-8787",
"Lynn Presnell, 887-1212",
"Holly Gaddis, 223-8878",
"Sam Wiggins, 486-0998","Bob Kain, 586-8712",
"Tim Haynes, 586-7676",
"Warren Gaddis, 223-9037",
"Jean James, 678-4939",
"Ron Palmer, 486-2783"};
*/
const int SIZE = 11;
string input;
bool found = false;
ifstream file;
file.open("phoneList.txt");
cout<<"Enter a name or phone number to search:\t";
cin>> input;
for(int i = 0; i < SIZE; i++)
{
if(phoneList[i].find(input)!=string::npos)
{
found=true;
cout << phoneList[i]<<endl;
}
}
if(!found)
cout << "Name not found.\n";
file.close();
return 0;
}
|