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?
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.