hey what's up guys, I'm writing some C++ code used to do math operations on polynomials that are contained in a input file. Right now I'm stuck on the actual streaming in of the files. The .txt input file is in the format as follows
1 1
2 2
3 3
XXX
5 5
6 6
The XXX separates two different polynomials. The coefficient number comes first, and then the exponent. The problem that I believe I am having right now is that the eof bit is returned after the XXX is read in. The debug seems to indicate that the XXX is actually read in, but the stream then returns eof. I may be wrong, but that's what the problem seems most likely to be.
This is my code where the file is streamed in
in >> tempcoef >> tempexpo;
while(in)
{
n.newterm(tempexpo, tempcoef);
in >> tempcoef >> tempexpo;
if (!in)
{
in.ignore(2);
in >> tempcoef >> tempexpo;
while(in)
{
n2.newterm(tempexpo, tempcoef);
in >> tempcoef>> tempexpo;
}
}
}
in is my input file, n and n2 are classes that contain linked lists, tempexpo and tempcoef are variables used to store the numbers, and newterm is a function i created to insert nodes in the linked lists