std::cout is not printing in console/terminal

Mukit, Ataul - Feb 26 '19 - - Dev Community

Suppose in a C++ program, you are doing this but nothing appears in the console or terminal window.

std::cout << "running 1 ..";

This may happen because std::cout is writing to output buffer which is waiting to be flushed.
If no flushing occurs nothing will print.

So you may have to flush the buffer manually by doing the following:

        std::cout.flush();

However, if you call std::endl at the end, then it will invoke the flush, so you wouldn't have to call it manually.

If you write std::cout << "running 1 .." << std::endl;

You would see output is now showing in the console or terminal window.

Thanks https://dev.to/cnskn for pointing it out.

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Terabox Video Player