I am working on a program that takes a redirect file as input. For example, if my program is called Fu, then I will call the program ./foo & lt; Input.txt
. I am running through my program, those files are formatted with an integer on the first line, two integers on the second line, I think some files have built-in characters, although the first line I need to ignore is.
3 1 8
some sort of
3 t 1 8
I just go to cin> & Gt; Var & gt; & Gt; Var 2 & gt; & Gt; Var3;
But when that excessive T is thrown into the mix then it screws all the upwards what will be the best way to work around this problem? Is there any way when I tell the first variable again that it will leave the remaining line? Or will I use the getline
function and then parse somehow? Thank you.
if the file is of the form
[number] garbage [number ] [Number] garbage
and you know that the number is always in the right position on the line, then I use std :: getline (). To read each line, attempts to read the expected numbers from each row that you have read.
Comments
Post a Comment