Hi friends,

I'm retrieving some information from a input file with 10 columns and I need to get the first 3 columns and set into 3 different variables and the last 7 in the same variable.

I was using "ifstream" and ">>" like:

myfile >> stringA;
myfile >> stringB;

...

I was thinking to use this for the 3 initials columns and I'm in doubt about the others columns.

Thanks a lot!

Hi Nathan,

String:

100A 200B 300B A B C D E F G H I J

Then the idea is:

var1 receive 100A
var2 receive 200B
var3 receive 300B
var4 receive A B C D E F G H I J

Depending on your knowledge you can do a couple things. You could read the entire line into a string and then use a stringstream to parse it. you could put the other 7 variables in a vector or some other sort of container. If you want all 7 in the same string then after you read in the first 3 variables then just use getline and read the rest into the fourth variable.

This question has already been answered. Start a new discussion instead.