reading 3 ints from one line, then 3 from another
Hi, I’m having some trouble getting a program to work. What I’m trying to do is input 3 ints from a specific line in an external .cpp file.
say I need to find out what ints x, y, and z are. the external .cpp file reads:
"
1 10 1900
4 20 2000
6 66 1666
"
what would I do to first read line one, making x=1, y=10, and z=1900, then after using the data, read the next line, making x=4, y=20, and z=2000?
if I write:
infile>>x>>y>>z;
it will only read the last line in the file. making x=6 and so on.
would getline work? and if so, how?
getline can read a specific line, but can only take that line in as a string, not 3 ints.