summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAssaf Gordon <assafgordon@gmail.com>2015-09-18 18:13:05 (GMT)
committerAssaf Gordon <assafgordon@gmail.com>2015-09-18 18:13:05 (GMT)
commitf56c28cc8d36d847de0ba501b901e301b0cfcc4e (patch)
treedbdec457ca7aae6d021f84a81ef9670c6ae0daef
parent903bc8a35c03a6d5b05588e28fd545c7eaffc4b5 (diff)
downloadposix-libc-examples-master.zip
posix-libc-examples-master.tar.gz
posix-libc-examples-master.tar.bz2
printf example: add %s alignmentHEADmaster
-rw-r--r--printf-examples.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/printf-examples.c b/printf-examples.c
index f6ea009..2bb6020 100644
--- a/printf-examples.c
+++ b/printf-examples.c
@@ -12,7 +12,10 @@ void printf_substring()
//If the string is shorter than 5 characters,
//it must be NUL terminated.
const char *data2= "foo";
- printf("First 5 characters = '%.5s'\n", data2);
+ printf("up to first 5 characters = '%.5s'\n", data2);
+
+ //variable length with fixed alignment and padding
+ printf("up to first 5 characters (aligned) = '%*.*s'\n", 5, 5, data2);
}
void printf_varlen_substr()