Created
March 19, 2017 19:38
-
-
Save anonymous/b2f16af8f17e2636023f6f9ab927aa3f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
This program allows users to search through an array of string objects | |
In this instance they can search through an array of names and phone numbers | |
*/ | |
#include<iostream> | |
#include<string> | |
using namespace std; | |
int main() | |
{ | |
const int SIZE = 10; | |
string namesAndNumbers[SIZE] = { | |
"Renee Javens, 678-1223", "Joe Looney, 586-0097", | |
"Geri Palmer, 223-8787", "Lynn Presnell, 887-1212", | |
"Bill Wolfe, 223-8878", "Sam Wiggins, 486-0998", | |
"Bob Kain, 586-8712", "Tim Haynes, 586-7676", | |
"John Johnson, 223-9037", "Jean James, 678-4939",}; | |
//greet the user, ask them for text to search wtih | |
string search; | |
cout << "Please type a name or partial name: "; | |
cin >> search; | |
for (int count = 0; count < SIZE; count++) | |
{ | |
if (search.compare(namesAndNumbers[count])) | |
cout << namesAndNumbers[count]; | |
} | |
system("pause"); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment