Datasheet
The C and C++ Libraries
4-76 Copyright © 1999-2001 ARM Limited. All rights reserved. ARM DUI 0067D
printf family
The
printf
family consists of
_printf()
,
printf()
,
_fprintf()
,
fprintf()
,
vprintf()
,
and
vfprintf()
. All these functions use
__FILE
opaquely and depend only on the
functions
fputc()
and
ferror()
. The functions
_printf()
and
_fprintf()
are identical to
printf()
and
fprintf()
except that they cannot format floating-point values.
The standard output functions of the form
_printf(...)
are equivalent to:
fprintf(& __stdout, ...)
where
__stdout
has type
__FILE
.
scanf family
The
scanf()
family consists of
scanf()
and
fscanf()
. These functions depend only on
the functions
fgetc()
,
__FILE
, and
__backspace()
.
The standard input form
scanf(...)
is equivalent to:
fscanf(& __stdin, ...)
where
__stdin
has type
__FILE
.
fwrite(), fputs, and puts
If you define your own version of
__FILE
, and your own
fputc()
and
ferror()
functions
and the
__stdout
object, you can use all of the
printf()
family,
fwrite()
,
fputs()
, and
puts()
unchanged from the library. Example 4-19 shows how to do this. Consider
modifying the system routines if you require real file handling.
Example 4-19 printf() and __FILE
#include <stdio.h>
struct __FILE {
int handle;
/* Whatever you need here (if the only files you are using
is the stdoutput using printf for debugging, no file
handling is required) */
};
FILE __stdout;
int fputc(int ch, FILE *f)
{
/* Your implementation of fputc */
return ch;
}
int ferror(FILE *f)