summaryrefslogtreecommitdiff
path: root/snprintandf.c
diff options
context:
space:
mode:
Diffstat (limited to 'snprintandf.c')
-rw-r--r--snprintandf.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/snprintandf.c b/snprintandf.c
new file mode 100644
index 0000000..17707a2
--- /dev/null
+++ b/snprintandf.c
@@ -0,0 +1,18 @@
+#include <u.h>
+#include <libc.h>
+#include <stdio.h>
+
+void
+main()
+{
+ char *s;
+ int l;
+
+ s = malloc(128);
+ l = snprint(s, 128, "%s%s", "hi", "there");
+ print("%s(%d)\n", s, l);
+ l = snprintf(s, 128, "%s%s", "hi", "there");
+ print("%s(%d)\n", s, l);
+ free(s);
+ exits(0);
+}