1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
kolbaska11 [484]
4 years ago
12

Write a program that has an array of at least 50 string objects that hold people’s names and phone numbers. The program then rea

ds lines of text from a file named phonebook into the array. The program should ask the user to enter a name or partial name to search for in the array. All entries in the array that match the string entered should be displayed-- thus there may be more than one entry displayed. The program prints the message "Enter a name or partial name to search for: " and then after the user enters some input and hits return, the program skips a line, and prints the heading: "Here are the results of the search:", followed by each matched string in the array on a line by itself. Input Validation: None
Computers and Technology
1 answer:
Readme [11.4K]4 years ago
8 0

Answer:

See explaination

Explanation:

#include <iostream>

#include <fstream>

#include <string>

using namespace std;

int main()

{

const int SIZE = 50;

string phoneDirectory[SIZE];

int size=0;

string name; //name to look for

ifstream inFile;

inFile.open("phonebook");

while (!inFile.fail()) {

getline(inFile,phoneDirectory[size]);

size++;

}

inFile.close();

// Get a name or partial name to search for.

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

getline(cin, name);

cout << "\nHere are the results of the search: " << endl;

int numberEntriesFound = 0;

for (int k = 0; k < size; k++)

{

if (phoneDirectory[k].find(name.data(), 0) < phoneDirectory[k].length())

{

numberEntriesFound ++;

cout << phoneDirectory[k] << endl;

}

}

if (numberEntriesFound == 0)

cout << "\nNo Entries were found for " << name;

return 0;

}

You might be interested in
In the year, , the American Department of Defense put a military research network, called ARPANET online.
mario62 [17]

Answer:

November 21st of 1969.

Explanation:

In the year, 1969, the American Department of Defense put a military research network, called ARPANET online.

3 0
2 years ago
0111101101010110101110110001001011101001011101101010101010110101
rodikova [14]

Answer:

binary digits in computer system it belongs

4 0
3 years ago
Which folder does the ipad saves my pictures?
saw5 [17]
It will save it in the pre-installed iphotos application.
Hope this helps. <span />
4 0
3 years ago
Read 2 more answers
U2- an example of __________ is an attempt by an unauthorized user to gain access to a system by posing as an authorized user.
Ivan
The answer is "masquerade".
4 0
3 years ago
Help meeeeeeeeeeeeeee please​
bija089 [108]

Answer:

Explanation:My explanation is above my comment :)

3 0
3 years ago
Other questions:
  • Where can you change your web page SafeSearch settings?
    8·1 answer
  • Esther has acquired an associate's degree in information technology and certifications in PageMaker and Illustrator. Which caree
    8·2 answers
  • Linguist study
    9·1 answer
  • A web __________, such as internet explorer or mozillaâs firefox, allow users to access the world wide web.
    10·1 answer
  • . Business-to-business integration (B2Bi) is vital for efficient and accurate flow of data across internal ISs and external busi
    11·1 answer
  • When public relations professionals make provocative statements in newsgroups to get people to visit an organization's website o
    10·1 answer
  • 1. The global economy involves trading between people from different _____
    8·1 answer
  • For what purpose is keylogging software used? a. To automatically translate input to another language as the user enters data b.
    10·1 answer
  • PLEASE HELP ASAP<br> Which technology encrypts traffic between a web browser and a website?
    10·2 answers
  • If you double the force of and object what happens to the acceleration
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!