I have a few std::cout
statements and few of them do not print output to console till program ends. But it i put getchar()
, it starts printing output. Why does it happen, can someone please explain?
The issue may be because you are not trying to flush your output. You can try like this:
std::cout << "some text" << std::flush;
or like
std::cout << "some text" << std::endl;
The standard output is buffered and on newline the buffer is flushed.