Read two words in one element of array

So I need to have my program read in two words into a single element in an array from a data file. So say I have this file named names.txt and it has
1.joe Erica
2 john Samantha
3 Austin Jordan
...
How do I get it to read in the names but also forget about the number? Also how can I then get it to search through the array and output where the name is in both columns?
To ignore the numbers, you can just read them into a throw-away variable, like:
1
2
3
string ignore, name;
file >> ignore; // read in number
getline(file, name); // read in name 


The number will be in 'ignore', and the name will be in 'name' which you can then put into an array.
As ugly as it is (for instantiating a useless object), I think Arslan's solution gets the right idea.

I considered file.ignore(std::numeric_limits<std::streamsize>::max(), ' '); but that assumes the values are separated by plain-old spaces and not tabs or some other crazy locale-specific whitespace character. That's not a reasonable assumption in the general case.
Tabs (both horizontal and vertical) are also considered whitespace
Topic archived. No new replies allowed.