Originally Posted by
CornedBee
Well, what does it do in the case where it doesn't work, and what do you expect it to do?
Assuming the line is :
show 0
I expect the program to enter this block because the istringstream did indeed contain a line containing show and some integer. But it does not enter that block of code.
Code:
if(iss >> show >> poly)
{
//do something
}
This is one of the blocks inside a while loop that assigns one line of the file to the istringstream. I have ruled out a problem with the while loop or the assignment of the line to the istringstream because I checked to see what istringstream contained each time around.
Here is the loop:
Code:
int poly, argument, coefficient, exponent;
char colon = ':';
char assignment = '=';
char multiply = '*';
while(INPUTFILE && INPUTFILE.peek() != EOF)
{
getline(INPUTFILE, theTerms);
iss.str(theTerms);
if(iss >> poly >> colon)
{
locationOfPoly = poly;
while(iss >> coefficient >> exponent)
{
tPoly.insert(exponent, coefficient);
}
//postcondition: all info has been extracted from iss so assign tmpPoly
//to Poly[locationOfPoly]
Poly[locationOfPoly] = tPoly;
}
if(iss >> poly >> assignment >> poly >> multiply >> poly)
{
Poly[poly] = Poly[poly] * Poly[poly];
}
if(iss >> show >> poly)
{
locationOfPoly = poly;
cout <<"Poly[" << locationOfPoly << "] = " << Poly[locationOfPoly] << "\n";
}
}//end while INPUTFILE loop