Defined in header <stdlib.h> | ||
|---|---|---|
int strfromf( char *restrict s, size_t n, const char *restrict format, float fp ); | (since C23) | |
int strfromd( char *restrict s, size_t n, const char *restrict format, double fp ); | (since C23) | |
int strfroml( char *restrict s, size_t n, const char *restrict format, long double fp ); | (since C23) |
Converts a floating-point value to a byte string.
The functions are equivalent to snprintf(s, n, format, fp), except that the format string shall only contain the character %, an optional precision that does not contain an asterisk *, and one of the conversion specifiers a, A, e, E, f, F, g, or G, which applies to the type double, float, or long double) indicated by the function suffix (rather than by a length modifier). Use of these functions with any other format string results in undefined behavior.
| s | - | pointer to a character string to write to |
| n | - | up to n - 1 characters may be written, plus the null terminator |
| format | - | pointer to a null-terminated byte string specifying how to interpret the data |
| fp | - | floating-point value to convert |
The number of characters that would have been written had n been sufficiently large, not counting the terminating null character. Thus, the null-terminated output has been completely written if and only if the returned value is both nonnegative and less than n.
|
(C99)(C11)(C11)(C11)(C11) | prints formatted output to stdout, a file stream or a buffer (function) |
|
(C99)(C99) | converts a byte string to a floating point value (function) |
© cppreference.com
Licensed under the Creative Commons Attribution-ShareAlike Unported License v3.0.
https://en.cppreference.com/w/c/string/byte/strfromf