strfroml(3)

strfroml3

Convert floating point value to ascii string

Part of strfromd(3).

Usage

#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);

Library

Standard C Library (libc, -lc)

Overview

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.

Standards

Functions strfromd(), strfromf(), and strfroml() conform to ISO/IEC 9899:2024 (“ISO C23”).

From base 16.0-CURRENT-20261027-61c70dc16a79 in FreeBSD 16.0-CURRENT (2026-10-27). Parsed by carta from the page's mdoc source.