Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

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 eclipse stopped to give console output. e.g.:
cout<<"test";
doesn't get displayed.

But it's not every where... another example:

// File path as argument
int main(int argc, char* argv[]) {
if (argc != 2) {
    cout
            << "ERROR: Wrong amount of arguments! Only one allowed...
";
    cout << "
" << "Programm closed...

";
    exit(1);
}

CommandConverter a(argv[1]);
cout<<"test";
a.getCommandsFromCSV();
cout<<"test2";

return 0;
}

The error message is displayed correctly if the argument is missing. But if the argument is there and the program continues the test outputs:

cout<<"test";
cout<<"test2";

are not displayed...
I am missing something obvious?

Thanks in advance!

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
462 views
Welcome To Ask or Share your Answers For Others

1 Answer

You need to end output strings with newline, e.g.: `cout << "test "``. 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).


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...