No console output on cout

前端 未结 7 2073
情歌与酒
情歌与酒 2020-12-19 06:11

Good morning,

I have a problem with Eclipse IDE for C/C++ Developers.

I\'m writting a smal tool for converting Strings. While testing on some point e

相关标签:
7条回答
  • 2020-12-19 06:29

    For me installing the 32 bit versions of Eclipse (Indigo 3.7) and the 32 bit Java JDK/JRE did not work. I use the much quicker solution from the Eclipse CDT/User/FAQ:

    Quote from Eclipse CDT/User/FAQ - Eclipse console does not show output on Windows:

    Eclipse console does not show output on Windows In Eclipse CDT on Windows, standard output of the program being run or debugged is fully buffered, because it is not connected to a Windwos console, but to a pipe. See bug 173732 for more details. Either add fflush calls after every printf or add the following lines in the start of the main function:

    setvbuf(stdout, NULL, _IONBF, 0); 
    setvbuf(stderr, NULL, _IONBF, 0);
    
    0 讨论(0)
  • 2020-12-19 06:31

    You need to end output strings with newline, e.g.: `cout << "test\n"``. The reason is that the standard output is buffered and the buffer is flushed on newline. There probably exists a way to flush the cout buffer without outputting a newline, but I don't know it by heart. Probably includes access to the underlying streambuf (via the rdbuf method).

    0 讨论(0)
  • 2020-12-19 06:33

    This Happens when you debug your code and dont see the output till the last. use

    cout<<"what ever overloads"<< flush;
    

    to see the output immediately on stdout(console)

    0 讨论(0)
  • 2020-12-19 06:40

    I had a similar problem. In my case the program would give output if run from the command line but not from eclipse console. The solution was to use the 32 bit version of eclipse and not the 64 bit one.

    I read that it was a bug. Might not be the same issue though.

    0 讨论(0)
  • 2020-12-19 06:47

    try outputting a space at the beginning of each line

    cout << " " << .....

    0 讨论(0)
  • 2020-12-19 06:54

    I was also searching for exactly this information when I found this on the Microsoft website http://support.microsoft.com/kb/94227

    I think a simple method is to use std::flush when you want to force flushing the internal buffer that cout uses

    *std::cout << ... << std::flush;*
    
    0 讨论(0)
提交回复
热议问题