-
Overriding Cin with Cout
I need some way to replace a Cin with something that prints to the dos screen(cout) before the user actually enters anything into the Cin. I finally got multi-threading to work, but now whenever I want it to display something with thread 2, it waits for the person to enter something for the Cin from thread 1 rather than just displaying it immediately. I've done some testing, so I'm sure the multi-threading is working, its just this Cin problem. Thanks for any help.
-
IIRC cin and cout is not thread safe. Have you tried just flushing the buffer?
-
yea if you want cin and cout to behave on threads you need to synchronize the access to them, use critical sections or a semaphore or something.
-
err I just started programming a couple days ago, so I don't know how to do that stuff. Is there any other relatively easy ways to print text and to get input without those? Also you talked about flushing the buffer, how would I do that?
-
Wait, you just started programming a few days again and you are already making multi-threaded applications? I think you need to spend some time on the basics.
-
no i think he means kindof a question and answer type of thing