Mac Developer Library Developer
Search

 

This manual page is part of Xcode Tools version 5.0

To obtain these tools:

If you are running a version of Xcode Tools other than 5.0, view the documentation locally:

  • In Xcode

  • In Terminal, using the man(1) command

Reading manual pages

Manual pages are intended as a quick reference for people who already understand a technology.

  • To learn how the manual is organized or to learn about command syntax, read the manual page for manpages(5).

  • For more information about this technology, look for other documentation in the Apple Developer Library.

  • For general information about writing shell scripts, read Shell Scripting Primer.




STRFMON(3)               BSD Library Functions Manual               STRFMON(3)

NAME
     strfmon, strfmon_l -- convert monetary value to string

SYNOPSIS
     #include <monetary.h>

     ssize_t
     strfmon(char *restrict s, size_t maxsize, const char *restrict format, ...);

     #include <monetary.h>
     #include <xlocale.h>

     ssize_t
     strfmon_l(char *restrict s, size_t maxsize, locale_t loc, const char *restrict format, ...);

DESCRIPTION
     The strfmon() function places characters into the array pointed to by s, as controlled by the string
     pointed to by format.  No more than maxsize bytes are placed into the array.

     While the strfmon() function uses the current locale, the strfmon_l() function may be passed a locale
     directly. See xlocale(3) for more information.

     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:

     •   Zero or more of the following flags:

         =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 pre-fixing prefixing
              fixing them with a negative sign.  This is the default.

         (    Enclose negative values in parentheses.

         !    Do not include a currency symbol in the output.

         -    Left justify the result.  Only valid when a field width is specified.

     •   An optional minimum field width as a decimal number.  By default, there is no minimum width.

     •   A `#' sign followed by a decimal number specifying the maximum expected number of digits after the
         radix character.

     •   A `.' character followed by a decimal number specifying the number of digits after the radix char-acter. character.
         acter.

     •   One of the following conversion specifiers:

         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.

RETURN VALUES
     If the total number of resulting bytes, including the terminating NULL byte, is not more than maxsize,
     strfmon() returns the number of bytes placed into the array pointed to by s, not including the termi-nating terminating
     nating NULL byte.  Otherwise, -1 is returned, the contents of the array are indeterminate, and errno is
     set to indicate the error.

ERRORS
     The strfmon() function will fail if:

     [E2BIG]            Conversion stopped due to lack of space in the buffer.

     [EINVAL]           The format string is invalid.

     [ENOMEM]           Not enough memory for temporary buffers.

EXAMPLE
             #include <stdio.h>
             #include <monetary.h>
             #include <locale.h>

             int main() {
                     char buf[200];
                     setlocale(LC_ALL, "en_US");
                     (void)strfmon (buf, sizeof(buf)-1, "%n" , 123456.78);
                     printf("%s0, buf);
             }

SEE ALSO
     localeconv(3), xlocale(3)

STANDARDS
     The strfmon() function conforms to IEEE Std 1003.1-2001 (``POSIX.1'').

AUTHORS
     The strfmon() function was implemented by Alexey Zelkin <phantom@FreeBSD.org>.

     This manual page was written by Jeroen Ruigrok van der Werven <asmodai@FreeBSD.org> based on the stan-dard's standard's
     dard's text.

BUGS
     The strfmon() function does not correctly handle multibyte characters in the format argument.

BSD                            October 12, 2002                            BSD

Reporting Problems

The way to report a problem with this manual page depends on the type of problem:

Content errors
Report errors in the content of this documentation with the feedback links below.
Bug reports
Report bugs in the functionality of the described tool or API through Bug Reporter.
Formatting problems
Report formatting mistakes in the online version of these pages with the feedback links below.

Feedback