Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 31 Jan 2023 00:39:09 GMT
From:      Konstantin Belousov <kib@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org
Subject:   git: 9149830359bf - stable/13 - strfmon(3): Add an EXAMPLES section
Message-ID:  <202301310039.30V0d9Qs059573@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch stable/13 has been updated by kib:

URL: https://cgit.FreeBSD.org/src/commit/?id=9149830359bfc816e916d24fab4acd5c0e70e13d

commit 9149830359bfc816e916d24fab4acd5c0e70e13d
Author:     Jose Luis Duran <jlduran@gmail.com>
AuthorDate: 2022-11-08 20:36:57 +0000
Commit:     Konstantin Belousov <kib@FreeBSD.org>
CommitDate: 2023-01-31 00:38:19 +0000

    strfmon(3): Add an EXAMPLES section
    
    (cherry picked from commit cdd9d92dade61a6b5c37b758e9533a076bb5a2de)
---
 lib/libc/stdlib/strfmon.3 | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git a/lib/libc/stdlib/strfmon.3 b/lib/libc/stdlib/strfmon.3
index 924c82109a68..1ddfb77cb0ac 100644
--- a/lib/libc/stdlib/strfmon.3
+++ b/lib/libc/stdlib/strfmon.3
@@ -149,6 +149,31 @@ The
 .Fn strfmon_l
 function returns the same values as
 .Fn strfmon .
+.Sh EXAMPLES
+The following example will format the value
+.Dq Li 1234567.89
+to the string
+.Dq Li $1,234,567.89 :
+.Bd -literal -offset indent
+#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().\\n");
+		return (1);
+	}
+
+	strfmon(string, sizeof(string) - 1, "%n", money);
+	printf("%s\\n", string);
+}
+.Ed
 .Sh ERRORS
 The
 .Fn strfmon



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202301310039.30V0d9Qs059573>