istream

I'm hoping I'm just missing something simple... I am making a polynomial linked list and am having trouble with my istream.
When the following two lines are invoked, the >> should be over-loaded by the following method.
polynomial p1;
cin >> p1;

istream& operator>> ( istream& is, polynomial& p )
{
term curr;

while (is.peek() != '\n')
{
is >> curr.coef;
is >> curr.expn;
p.insertLast(curr);
}
// The newline.
p.sort();

return is;
}

Everytime I get to this point, it skips over it.
Is "is.peek() != '\n' the best way to create the while loop?
Thank you for your time!
i think what you need is a cin.ignore(); after cin...
or somewhere else...
this skipping happened to me too because i mixed input methods... and the return character was pinned on the input stream, which practically was like pressing enter ...
Thanks! What do you mean by after cin? The line after?
Topic archived. No new replies allowed.