NAME
strfromd, strfromf, strfroml – convert floating point value to ASCII string
LIBRARY
Standard C Library (libc, -lc)
SYNOPSIS
#include <stdlib.h>
int
strfromd(char * restrict str, size_t size, const char * restrict format, double fp);
int
strfromf(char * restrict str, size_t size, const char * restrict format, float fp);
int
strfroml(char * restrict str, size_t size, const char * restrict format, long double fp);
DESCRIPTION
Functions strfromd(), strfromf(), and strfroml() convert the floating-point value fp to a null terminated string, storing at most size bytes (including the terminating null character) into the array pointed to by str.
These functions are equivalent to snprintf(s, n, format, fp), except that default argument promotions are not applied to fp, and the format string is restricted. It shall consist of exactly the character ‘%’, followed by an optional precision that does not contain an asterisk ‘*’, followed by one of the conversion specifiers a, A, e, E, f, F, g, or G. The conversion specifier applies to the type indicated by the function suffix, rather than by a length modifier.
Use of any other format string results in undefined behaviour, as does any undefined behaviour inherited from snprintf(3) per se. In case of a format string not specified by the standard, the string ‘EDOOFUS’ is written to str, subject to the same truncation rules as a successful conversion, and errno is set to EDOOFUS.
RETURN VALUES
The strfromd(), strfromf(), and strfroml() functions, as per snprintf(3), return the number of characters( not counting the terminating null character) that would have been written had n been sufficiently large. Thus, the null terminated output has been completely written if and only if the returned value is both nonnegative and less than size.
ERRORS
- [EDOOFUS]
-
The format string is not of the form the standard specifies.
SEE ALSO
STANDARDS
Functions strfromd(), strfromf(), and strfroml() conform to ISO/IEC 9899:2024 (“ISO C23”).