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, which themselves call the system I/O functions, which are target-dependent. To retarget input/output, you can either avoid the high-level library functions, or redefine the lower-level functions, either the low-level library functions or, below them, the system I/O functions, and then use them through the high-level library 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.

Was this page helpful? Yes No