summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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()