In the searchPhoneNumber i want to the user to type in Company name and if found display number and what line it was found on! If not found output "not found" Please HELP - i'm so nooob at this...
You'd need to open a stream to the file using ifstream fs(filename)
Then you would do something along these lines:
1 2 3 4 5 6 7 8 9 10 11 12 13
int lineNum = 0;
string line;
string correctPhoneNumber;
while(getline(fs,line))
{
if(line == company)
{
getline(fs, correctPhoneNumber);
cout << "The company's number is "<< correctPhoneNumber << " found at line " << (lineNum+1);
break;
}
lineNum++;
}
The method I've given is based on how your addNumber worked. Personally I'd have company name and number on the same line separated by a ';' rather than having them on separate lines.