2.12. Tailoring the input/output functions
The higher‑level input/output, such as the functions fscanf() and fprintf(), and the C++ object std::cout, are not target‑dependent. However, the higher‑level functions perform input/output by calling lower‑level functions that are target‑dependent. To retarget input/output, you can either avoid these higher‑level functions or redefine the lower‑level functions.
See the rt_sys.h include file for more information on I/O functions.
Also see Writing reentrant and thread‑safe code.