(gmp.info.gz) Formatted Output Functions
Info Catalog
(gmp.info.gz) Formatted Output Strings
(gmp.info.gz) Formatted Output
(gmp.info.gz) C++ Formatted Output
Functions
=========
Each of the following functions is similar to the corresponding C
library function. The basic `printf' forms take a variable argument
list. The `vprintf' forms take an argument pointer, see Variadic
Functions (libc)Variadic Functions, or `man 3 va_start'.
It should be emphasised that if a format string is invalid, or the
arguments don't match what the format specifies, then the behaviour of
any of these functions will be unpredictable. GCC format string
checking is not available, since it doesn't recognise the GMP
extensions.
The file based functions `gmp_printf' and `gmp_fprintf' will return
-1 to indicate a write error. Output is not "atomic", so partial
output may be produced if a write error occurs. All the functions can
return -1 if the C library `printf' variant in use returns -1, but this
shouldn't normally occur.
- Function: int gmp_printf (const char *FMT, ...)
- Function: int gmp_vprintf (const char *FMT, va_list AP)
Print to the standard output `stdout'. Return the number of
characters written, or -1 if an error occurred.
- Function: int gmp_fprintf (FILE *FP, const char *FMT, ...)
- Function: int gmp_vfprintf (FILE *FP, const char *FMT, va_list AP)
Print to the stream FP. Return the number of characters written,
or -1 if an error occurred.
- Function: int gmp_sprintf (char *BUF, const char *FMT, ...)
- Function: int gmp_vsprintf (char *BUF, const char *FMT, va_list AP)
Form a null-terminated string in BUF. Return the number of
characters written, excluding the terminating null.
No overlap is permitted between the space at BUF and the string
FMT.
These functions are not recommended, since there's no protection
against exceeding the space available at BUF.
- Function: int gmp_snprintf (char *BUF, size_t SIZE, const char *FMT,
...)
- Function: int gmp_vsnprintf (char *BUF, size_t SIZE, const char
*FMT, va_list AP)
Form a null-terminated string in BUF. No more than SIZE bytes
will be written. To get the full output, SIZE must be enough for
the string and null-terminator.
The return value is the total number of characters which ought to
have been produced, excluding the terminating null. If RETVAL >=
SIZE then the actual output has been truncated to the first SIZE-1
characters, and a null appended.
No overlap is permitted between the region {BUF,SIZE} and the FMT
string.
Notice the return value is in ISO C99 `snprintf' style. This is
so even if the C library `vsnprintf' is the older GLIBC 2.0.x
style.
- Function: int gmp_asprintf (char **PP, const char *FMT, ...)
- Function: int gmp_vasprintf (char **PP, const char *FMT, va_list AP)
Form a null-terminated string in a block of memory obtained from
the current memory allocation function ( Custom
Allocation). The block will be the size of the string and
null-terminator. The address of the block in stored to *PP. The
return value is the number of characters produced, excluding the
null-terminator.
Unlike the C library `asprintf', `gmp_asprintf' doesn't return -1
if there's no more memory available, it lets the current allocation
function handle that.
- Function: int gmp_obstack_printf (struct obstack *OB, const char
*FMT, ...)
- Function: int gmp_obstack_vprintf (struct obstack *OB, const char
*FMT, va_list AP)
Append to the current object in OB. The return value is the
number of characters written. A null-terminator is not written.
FMT cannot be within the current object in OB, since that object
might move as it grows.
These functions are available only when the C library provides the
obstack feature, which probably means only on GNU systems, see
Obstacks (libc)Obstacks.
Info Catalog
(gmp.info.gz) Formatted Output Strings
(gmp.info.gz) Formatted Output
(gmp.info.gz) C++ Formatted Output
automatically generated byinfo2html