Skip to content

Instantly share code, notes, and snippets.

Created March 19, 2017 19:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/b2f16af8f17e2636023f6f9ab927aa3f to your computer and use it in GitHub Desktop.
Save anonymous/b2f16af8f17e2636023f6f9ab927aa3f to your computer and use it in GitHub Desktop.
/*
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