Archives
D Programming
DD.gnu digitalmars.D digitalmars.D.bugs digitalmars.D.dtl digitalmars.D.dwt digitalmars.D.announce digitalmars.D.learn digitalmars.D.debugger C/C++ Programming
c++c++.announce c++.atl c++.beta c++.chat c++.command-line c++.dos c++.dos.16-bits c++.dos.32-bits c++.idde c++.mfc c++.rtl c++.stl c++.stl.hp c++.stl.port c++.stl.sgi c++.stlsoft c++.windows c++.windows.16-bits c++.windows.32-bits c++.wxwindows digitalmars.empire digitalmars.DMDScript |
c++ - Problem with input, no output
Using Digital Mars Compiler Version 8.38n and stlport. Win98SE. Compile and run, enter some numbers, press ctrl-Z for EOF. The output "Answer: " etc. never appears. Uncomment the indicated line, and all works as I expect. Am I doing something dumb? #include <iostream> #include <vector> #include <iterator> #include <algorithm> using namespace std; int main() { typedef double T; vector<T> scores; cout << "Enter scores, EOF to end: "; copy(istream_iterator<T>(cin), istream_iterator<T>(), back_inserter(scores)); // cout << "\nUncomment this line, problem goes away.\n"; cout << "Answer: " << scores.size() << '\n'; } Apr 14 2004
On Wed, 14 Apr 2004 18:33:08 -0700 in c++, David Harmon <<source netcom.com>> wrote:Using Digital Mars Compiler Version 8.38n and stlport. Win98SE. Apr 14 2004
try with an std::flush at the end: cout << "Answer: " << scores.size() << '\n' << flush;Using Digital Mars Compiler Version 8.38n and stlport. Win98SE. Compile and run, enter some numbers, press ctrl-Z for EOF. The output "Answer: " etc. never appears. Uncomment the indicated line, and all works as I expect. Am I doing something dumb? #include <iostream> #include <vector> #include <iterator> #include <algorithm> using namespace std; int main() { typedef double T; vector<T> scores; cout << "Enter scores, EOF to end: "; copy(istream_iterator<T>(cin), istream_iterator<T>(), back_inserter(scores)); // cout << "\nUncomment this line, problem goes away.\n"; cout << "Answer: " << scores.size() << '\n'; } Apr 15 2004
On Thu, 15 Apr 2004 12:19:36 -0700 in c++, "Pablo Aguilar" <paguilarg hotmail.com> wrote:try with an std::flush at the end: cout << "Answer: " << scores.size() << '\n' << flush; Apr 15 2004
|