1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
|
void searchFirst(ifstream& inData)
{
string searchName, firstName, lastName, phone, address,
upperSearch, upperFirstName;
cout << "Enter the first name of the person: ";
cin >> searchName;
cout << endl;
upperSearch = uppercaseString(searchName);
while (readFile(inData, firstName, lastName, phone, address))
{
upperFirstName = uppercaseString(firstName);
if (upperFirstName == upperSearch)
break;
}
if (inData)
{
cout << "Person found: " << endl;
printInfo(firstName, lastName, phone, address);
}
else
{
cout << searchName << " not found!" << endl << endl;
}
inData.clear();
inData.seekg(0);
}
bool readFile(ifstream& inData, string& firstName, string& lastName, string& phone, string& address)
{
getline(inData, firstName, ',');
extraSpaces(firstName);
getline(inData, lastName, ',');
extraSpaces(lastName);
getline(inData, phone, '\n');
extraSpaces(phone);
getline(inData, address, '\n');
extraSpaces(address);
return inData;
}
|