git: cdd9d92dade6 - main - strfmon(3): Add an EXAMPLES section
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Wed, 25 Jan 2023 09:03:24 UTC
The branch main has been updated by kib:
URL: https://cgit.FreeBSD.org/src/commit/?id=cdd9d92dade61a6b5c37b758e9533a076bb5a2de
commit cdd9d92dade61a6b5c37b758e9533a076bb5a2de
Author: Jose Luis Duran <jlduran@gmail.com>
AuthorDate: 2022-11-08 20:36:57 +0000
Commit: Konstantin Belousov <kib@FreeBSD.org>
CommitDate: 2023-01-25 09:02:55 +0000
strfmon(3): Add an EXAMPLES section
Reviewed by: kib
MFC after: 1 week
---
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