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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.