Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Doing homework assignment in my programming 2 class and every time I run the program is never finds anything that I am trying to look

Doing homework assignment in my programming 2 class and every time I run the program is never finds anything that I am trying to look up. What do I have in the wrong place

#include

#include

#include

using namespace std;

int main()

{

const int Num_People = 10;

const int Length = 27;

string people[Num_People] = { "Becky Warren, 555-1223",

"Geri Palmer, 555-8787",

"Lynn Presnell, 555-1212",

"Holly Gaddis, 555-8878",

"Sam Wiggins, 555-0998",

"Bob Kain, 555-8712",

"Tim Haynes, 555-7676",

"Warren Gaddis, 555-9037",

"Jean James, 555-4939",

"Ron Palmer, 555-2783" };

char lookUp[Length];

size_t strPos;

int index,count=0;

cout << "\tPeople and Phone Numbers ";

//Prompt the user to enter name or partial name

cout << "Enter a name or partial name to search for: ";

//read name or partial name

cin.getline(lookUp, 27);

//Find the name in all string objects

for (index = 0; index < 10; index++)

{

//if the name is found in the string, the starting

//position of name is returned into strPos

strPos = people[index].find(lookUp);

//strPos equal to no postions, if the name is

//not found in the string

if (strPos != string::npos)

{

//Print the string, in which the entered name is found

cout << people[index] << endl;

count++;//Increase the count

}

}

//count will be 0,if there are no matchings

if (count == 0)

cout << "No matching was found. "; system ("pause");

return 0;

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Application Development And Design

Authors: Michael V. Mannino

1st Edition

0072463678, 978-0072463675

More Books

Students also viewed these Databases questions

Question

=+7. Compare Walmarts new and old logos:

Answered: 1 week ago

Question

2 What are the implications for logistics strategy?

Answered: 1 week ago