Topic: <iostream > questions


Author: Tim Downey <downeyt@fiu.edu>
Date: 1998/11/16
Raw View
I have noticed a difference between <iostream.h> and <iostream> on MSVC
5.0, I do not have this problem using g++ on Windows 95.
Here is an example of a program that should continue until cin fails.
However, in order to stop the input with EOF, it is necessary to enter
Ctrl-z twice.

1. Can anyone explain why two ctrl-z's are needed in MSVC 5.0?
2. Also, using iostream.h or iostream, it is necessary to have the extra

cout << endl after the loop, or the final cout statement is ignored.
This
occurs on MSVC and g++. Why is this cout << endl necessary after
ctrl-z is entered?

#include <iostream>
using namespace std;

int main() {

 int num;

 while (cin >> num) {
  cout << "\t'" << num << "'" << endl;
 }
 cout << endl;
 cout << "final: " << num << endl;

 return 0;
}


--
_______________________________________________________________________
            Tim Downey
     (e-mail) downeyt@fiu.edu
      (www) http://www.cs.fiu.edu/~downeyt
---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html              ]





Author: brownsta@concentric.net (Stan Brown)
Date: 1998/11/16
Raw View
[posted and emailed]

downeyt@fiu.edu (Tim Downey) wrote:
>I have noticed a difference between <iostream.h> and <iostream> on MSVC
>5.0, I do not have this problem using g++ on Windows 95.
>Here is an example of a program that should continue until cin fails.
>However, in order to stop the input with EOF, it is necessary to enter
>Ctrl-z twice.

1. <iostream> and <iostream.h> are the new and old implementations,
respectively. Generally you can't mix them in an executable, and there
are multiple differences in their functioning.

2. I think you have run up against the same istream bug that I reported a
month ago in comp.lang.c++.moderated. The fix has already been posted on
the web site of Dinkumware, which is the company that maintains much of
the C++ library for MSVC. For the bug report and responses, search Deja
News for newsgroup comp.lang.c++.moderated, subject "weirdness", between
Oct 1 1998 and Oct 20 1998. Dennis Swanson's article shows where to find
the fixes (and which ones apply to this particular bug).

--
Stan Brown, Oak Road Systems, Cleveland, Ohio, USA
                      http://www.concentric.net/%7eBrownsta/
"I'm not even supposed to BE here!"  -- the mantra from /Clerks/
My reply address is correct as is. The courtesy of providing a correct
reply address is more important to me than time spent deleting spam.


[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html              ]