I have a file that contains phone number mapping in the form of:
4475825 9876523
The idea is to read the file into a vector called phoneMap which I have done. Now, I am trying to sort out how to find only the first number in the vector so I can return the second number to the main {}. I need the first seven characters
to compare to a second file so I can overwrite the second file's phone number with the second phone number in the array. I do not know how to use substr or at with the find(vector.xxx) or if there is a way to use a wild card.
This code finds the text ok:
vector<string>::iterator i;
i = find(phoneMap.begin(), phoneMap.end(), "4475825 9876523") ;
if (i != phoneMap.end())
{
cout << "Element found in phoneMap: " << *i << '\n' << " at position " << (i - phoneMap.begin() + 1) << endl;
}
else
{
cout << "Element not found in phoneMap\n\n";
}
But this code does not:
vector<string>::iterator i;
i = find(phoneMap.begin(), phoneMap.end(), "4475825") ;
if (i != phoneMap.end())
{
cout << "Element found in phoneMap: " << *i << '\n' << " at position " << (i - phoneMap.begin() + 1) << endl;
}
else
{
cout << "Element not found in phoneMap\n\n";
}
Any pointers would be greatly appreciated. Thank you.