0

Can I have 2 threads in the same process calling fprintf or fscanf at the same time?

One stream is written to by the first thread and is read by the second thread and the other stream is read by the first thread and is written to by the second thread. So, I don't have a situation of simultaneous writes or simultaneous reads to the same stream.

If the answer is no - Do I have an reentrant alternative in the printf/scanf family?

This questions follows some comments in: Thread communication via printf and scanf (linux)

Community
  • 1
  • 1
user302099
  • 635
  • 1
  • 5
  • 17

1 Answers1

2

They are thread-safe. See http://www.unix.org/whitepapers/reentrant.html

Igor Nazarenko
  • 2,184
  • 13
  • 10