Main index | Section 3 | Options |
#include <monetary.h>
#include <monetary.h>
#include <xlocale.h>
The strfmon_l() function takes an explicit locale argument, whereas the strfmon() function uses the current global or per-thread locale.
The format string is composed of zero or more directives: ordinary characters (not %), which are copied unchanged to the output stream; and conversion specifications, each of which results in fetching zero or more subsequent arguments. Each conversion specification is introduced by the % character. After the %, the following appear in sequence:
=f | A ' =' character followed by another character f which is used as the numeric fill character. |
^ | Do not use grouping characters, regardless of the current locale default. |
+ | Represent positive values by prefixing them with a positive sign, and negative values by prefixing them with a negative sign. This is the default. |
amp;( | Enclose negative values in parentheses. |
amp;! | Do not include a currency symbol in the output. |
- | Left justify the result. Only valid when a field width is specified. |
i | The double argument is formatted as an international monetary amount. |
n | The double argument is formatted as a national monetary amount. |
% | A '%' character is written. |
#include <stdio.h> #include <monetary.h> #include <xlocale.h>int main() { char string[100]; double money = 1234567.89;
if (setlocale(LC_MONETARY, "en_US.UTF-8") == NULL) { fprintf(stderr, "Unable to setlocale(). ); return (1); }
strfmon(string, sizeof(string) - 1, "%n", money); printf("%s , string); }
[E2BIG] | |
Conversion stopped due to lack of space in the buffer. | |
[EINVAL] | |
The format string is invalid. | |
[ENOMEM] | |
Not enough memory for temporary buffers. | |
This manual page was written by Jeroen Ruigrok van der Werven <Mt asmodai@FreeBSD.org> based on the standards' text.
STRFMON (3) | January 25, 2023 |
Main index | Section 3 | Options |
Please direct any comments about this manual page service to Ben Bullock. Privacy policy.
“ | I define UNIX as “30 definitions of regular expressions living under one roof.” | ” |
— Donald Knuth |