Datasheet

The C and C++ Libraries
ARM DUI 0067D Copyright © 1999-2001 ARM Limited. All rights reserved. 4-75
4.10 Tailoring the input/output functions
The higher-level input/output functions such as
fscanf()
and
fprintf()
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.
4.10.1 Dependencies on low-level functions
The dependencies of the higher-level function on lower-level functions is shown in
Table 4-14. If you define your own versions of the lower-level functions, you can use
the library versions of the higher-level functions directly.
fgetc()
uses
__FILE
, but
fputc()
uses
__FILE
and
ferror()
.
See the ANSI C Reference for syntax of the low-level functions.
Table 4-14 Input/output dependencies
Low-level object Description
fprintf
printf
fwrite
fputs
puts
fscanf
scanf
fread
read
fgets
gets
__FILE
The file structure xxxxxxxxxxx
__stdin
The standard input object of type
__FILE
------x-x-x
__stdout
The standard output object of type
__FILE
-x--x------
fputc()
Outputs a character to a file x x x x x - - - - - -
ferror()
Returns the error status accumulated during
file input/output
xxx--------
fgetc()
Gets a character from a file - - - - - x x x x x x
__backspace()
Moves file pointer to previous character - - - - - x x - - - -