Changeset View
Changeset View
Standalone View
Standalone View
lib/libc/stdio/printf.3
Show All 36 Lines | |||||
.Os | .Os | ||||
.Sh NAME | .Sh NAME | ||||
.Nm printf , fprintf , sprintf , snprintf , asprintf , dprintf , | .Nm printf , fprintf , sprintf , snprintf , asprintf , dprintf , | ||||
.Nm vprintf , vfprintf, vsprintf , vsnprintf , vasprintf, vdprintf | .Nm vprintf , vfprintf, vsprintf , vsnprintf , vasprintf, vdprintf | ||||
.Nd formatted output conversion | .Nd formatted output conversion | ||||
.Sh LIBRARY | .Sh LIBRARY | ||||
.Lb libc | .Lb libc | ||||
.Sh SYNOPSIS | .Sh SYNOPSIS | ||||
.Fd "#define _WITH_DPRINTF" | |||||
.In stdio.h | .In stdio.h | ||||
.Ft int | .Ft int | ||||
.Fn printf "const char * restrict format" ... | .Fn printf "const char * restrict format" ... | ||||
.Ft int | .Ft int | ||||
.Fn fprintf "FILE * restrict stream" "const char * restrict format" ... | .Fn fprintf "FILE * restrict stream" "const char * restrict format" ... | ||||
.Ft int | .Ft int | ||||
.Fn sprintf "char * restrict str" "const char * restrict format" ... | .Fn sprintf "char * restrict str" "const char * restrict format" ... | ||||
.Ft int | .Ft int | ||||
▲ Show 20 Lines • Show All 656 Lines • ▼ Show 20 Lines | if ((p = malloc(128)) == NULL) | ||||
return (NULL); | return (NULL); | ||||
va_start(ap, fmt); | va_start(ap, fmt); | ||||
(void) vsnprintf(p, 128, fmt, ap); | (void) vsnprintf(p, 128, fmt, ap); | ||||
va_end(ap); | va_end(ap); | ||||
return (p); | return (p); | ||||
} | } | ||||
.Ed | .Ed | ||||
.Sh COMPATIBILITY | .Sh COMPATIBILITY | ||||
Many application writers used the name | |||||
.Va dprintf | |||||
before the | |||||
.Fn dprintf | |||||
function was introduced in | |||||
.St -p1003.1 , | |||||
so a prototype is not provided by default in order to avoid | |||||
compatibility problems. | |||||
Applications that wish to use the | |||||
.Fn dprintf | |||||
function described herein should either request a strict | |||||
.St -p1003.1-2008 | |||||
environment by defining the macro | |||||
.Dv _POSIX_C_SOURCE | |||||
to the value 200809 or greater, or by defining the macro | |||||
.Dv _WITH_DPRINTF , | |||||
prior to the inclusion of | |||||
.In stdio.h . | |||||
For compatibility with GNU libc, defining either | |||||
.Dv _BSD_SOURCE | |||||
or | |||||
.Dv _GNU_SOURCE | |||||
prior to the inclusion of | |||||
.In stdio.h | |||||
will also make | |||||
.Fn dprintf | |||||
available. | |||||
.Pp | |||||
The conversion formats | The conversion formats | ||||
.Cm \&%D , \&%O , | .Cm \&%D , \&%O , | ||||
and | and | ||||
.Cm \&%U | .Cm \&%U | ||||
are not standard and | are not standard and | ||||
are provided only for backward compatibility. | are provided only for backward compatibility. | ||||
The effect of padding the | The effect of padding the | ||||
.Cm %p | .Cm %p | ||||
▲ Show 20 Lines • Show All 167 Lines • Show Last 20 Lines |