I have a text file with real data points aligned in a column that I am reading into C++ with the attached program. Initially I read it in using a traditional for loop but decided to get a little bit more fancy with the use of the vector class. The code at present is shown below and it works very well for reading in a single column of data. However, my question is, while retaining this same general vector class format, how can I read in multiple columns of data from a .txt or .csv file?
Depends on what is stored in those columns and how do you want data to be read.
If columns are of different types and rows denotes different entities (like phone book: first column is name, second is phone №), I would create a struct, provide operators >> and << for it and just use your current approach.