#include<iostream>
#include<cstring>
using namespace std;
int main() {
const int LENGTH = 30;
char contacts [][LENGTH] = {"Renee Javens, 678-1223", "Joe Looney, 586-0097", "Geri Palmer, 223-8787","Lynn Presnell, 887-1212", "Bill Wolfe, 223-8878", "Same Wiggins, 486-0998", "Bob Kain, 586-8712", "Tim Haynes, 586-7676", "John Johnson, 2223-9037", "Jean James, 678-4939", "Ron Palmer, 486-2783"};
const int SIZE = sizeof(contacts)/sizeof(contacts[0]);
char search[LENGTH] = {""};
char repeat = 'y', found;
int i;
do{
cout << endl << "Search contacts: ";
cin >> search;
i = SIZE;
found = 0;
while(0 <= i){
if(strstr(contacts[i], search)){
found = 1;
cout << "Found contact: " << contacts[i] << endl;
}
i --;
}
if(!found){
cout << "No such contact found!" << endl;
}
cout << endl << "Wanna continue? : ";
cin >> repeat;
cin.ignore();
repeat = tolower(repeat);
}while('y' == repeat);
return 0;
}
Download
Comments
Post a Comment