Hi there everyone, here is the problem. I have been thinking and I dont figure out how to solve this.

I have 2 threads running simultaneous and the both can ask for a string from the user. The problem is if I make a fgets() in thread 1 and user doesnt input right away, thread 2 can make a fgets() and the problem is that the buffer is the same - stdin. So it will basically run the fgets()'s sequentaly.

But what I want to do in this case is "suspend" the fgets() in thread 1 and retreive the info on stdin fgets() on thread 2 and then (after a '\n' of fgets() on thread 2) "restore" the fgets() on thread 1.

Can you help me on this? I have been thinking and it is quite possible that I will have to trick the fgets() with some global variable and some mutexs...

thanks in advance