looping in a phone dir

I need to write a program that requests a first and last name, lower case only.
then compares the name to a file the contains multiple entries of:
lastname, first
address1
address2

lastname, first
address1
address2

I have created a function to request the first and last name.
I have opened a stream (in main) to read the phone dir for last name, first name. address1. address2.

I do not know how to loop the requested name against the phone dir names..

sample code:
1
2
3
4
5
6
7
8
9
10
getName(firstName, lastName);

input.open("phoneDir");
getline(input, phoneBkName);
getline(input, phoneBkAddress1);
getline(input, phoneBkAddress2);

int spacePos = phoneBkName.find(' ');
phoneBkLast = phoneBkName.substr(0, spacePos-1);
phoneBkFirst = phoneBkName.substr(spacePos+1, 100);

//How to construct a loop to compare the requested name with the phoneDir name?

-Thank you
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
getName(firstName, lastName);

input.open("phoneDir");

while (firstName!=phoneBkFirst && lastName!=phoneBkLast)
{

getline(input, phoneBkName);
getline(input, phoneBkAddress1);
getline(input, phoneBkAddress2);

int spacePos = phoneBkName.find(' ');
phoneBkLast = phoneBkName.substr(0, spacePos-1);
phoneBkFirst = phoneBkName.substr(spacePos+1, 100);

}
Topic archived. No new replies allowed.