Search:
Forum
General C++ Programming
std::async not letting std::cout print t
std::async not letting std::cout print to terminal
Aug 2, 2019 at 9:52am UTC
bembel
(15)
Hi, I tried out the code found here
http://www.cplusplus.com/reference/future/future/wait_for/
When I run it on my machine, I don't get any output whatsoever before the std::async is finished. Once it it's done, I do get the correct amount of dots so I presume the while loop is reached while the std::async is still executing.
Why is std::cout getting blocked?
Aug 2, 2019 at 10:12am UTC
JLBorges
(13770)
To print out the character to the console immediately, flush the stream.
See:
https://en.cppreference.com/w/cpp/io/manip/flush
1
2
3
// *** modify line 21 ***
// std::cout << '.';
std::cout <<
'.'
<< std::flush
;
Aug 2, 2019 at 10:36am UTC
bembel
(15)
Thanks! Fixed it
Topic archived. No new replies allowed.
C++
Information
Tutorials
Reference
Articles
Forum
Forum
Beginners
Windows Programming
UNIX/Linux Programming
General C++ Programming
Lounge
Jobs