You copied the Doc URL to your clipboard.

Tailoring input/output functions in the C and C++ libraries

The input/output library functions, such as the high-level fscanf() and fprintf(), and the low-level fputc() and ferror(), and the C++ object std::cout, are not target-dependent. However, the high-level library functions perform input/output by calling the low-level ones. These low-level functions call system I/O functions that are target-dependent.

To retarget input/output, you can:

  • Avoid the high-level library functions.
  • Redefine the low-level library functions.
  • Redefine the system I/O functions.

Whether redefining the low-level library functions or redefining the system I/O functions is a better solution depends on your use. For example, UARTs write a single character at a time and the default fputc() uses buffering, so redefining this function without a buffer might suit a UART. However, where buffer operations are possible, redefining the system I/O functions would probably be more appropriate.