I have an input file that looks something like this:
0.1 239.402
0.4. 32342.34
0.7 4.924939
and so on...
I am trying to read it line by line using the fstream extraction operator >> I need a way to set a while loop condition that would stop at the end of the file, and I need a way to push the two as a pair onto two stacks The stacks are previously implemented in a class file Stack as linked lists I currently have something like
double a, double b
std::string t;
Stack av;
Stack bv;
while(i>>a>>t>>b&&(t=="\t"){
av.push(a);
bv.push(b);
}
i know i'm incorrect as it's not always a tab space gap. also the file starts with a couple of spaces until the first row and then has a random number of spaces until the second row, and then a next line. Is there a way to write a program where it knows when there is a double to read and use the random number of whitespaces as separation between a and b?
I hope this makes sense! Thanks so much for your help as I'm a beginner.