public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* Re: libstdc++/943: Problems reading in complex numbers in a loop
@ 2001-06-14 18:09 ljrittle
  0 siblings, 0 replies; only message in thread
From: ljrittle @ 2001-06-14 18:09 UTC (permalink / raw)
  To: bkoz, gcc-bugs, gcc-prs, schmid

Synopsis: Problems reading in complex numbers in a loop

State-Changed-From-To: feedback->closed
State-Changed-By: ljrittle
State-Changed-When: Thu Jun 14 18:09:17 2001
State-Changed-Why:
    The code posted as tcaus.C works as it is suppose to.  The
    reason peek() waits the first time through the loop is that
    the user has typed nothing.  Later times through the loop,
    '/n' is sitting on the input buffer thus peek() returns
    and is seen to be !eof.
    
    Try structuring your code as follows:
    
    #include <iostream>
    #include <complex>
    using namespace std;
    
    int
    main()
    {
      complex<double> c1;
    
      while (true)
      {
        cout << "Complex number c1: ";
        if (!(cin >> c1)) break;
      }
    }
    
    OR
    
    #include <iostream>
    #include <complex>
    using namespace std;
    
    int
    main()
    {
      complex<double> c1;
    
      do
        cout << "Complex number c1: ";
      while (cin >> c1);
    }
    
    I have taken the liberty to close this report

http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view&pr=943&database=gcc


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2001-06-14 18:09 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-06-14 18:09 libstdc++/943: Problems reading in complex numbers in a loop ljrittle

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).