aboutsummaryrefslogtreecommitdiff
path: root/tests/printf/test.c
diff options
context:
space:
mode:
authorRanger Harke <ranger.harke@autodesk.com>2013-09-19 17:24:31 -0400
committerRanger Harke <ranger.harke@autodesk.com>2013-09-19 17:24:31 -0400
commit61c9d6ede1fe9a91ae501dc019d2e5f97803943a (patch)
treec60349138d76cbda413292b56e0e62743523a49d /tests/printf/test.c
parentb72b6d897250cc7624b66832f720ff3bed6823a6 (diff)
Implement missing 'space' formatting flag
This flag causes space (padding) to be reserved for the sign even if the number is positive. It is basically the same as the 'plus' flag except that a space is displayed instead of a plus sign. The 'plus' flag takes precedence.
Diffstat (limited to 'tests/printf/test.c')
-rw-r--r--tests/printf/test.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/tests/printf/test.c b/tests/printf/test.c
index b01a99db..1c8ad9f7 100644
--- a/tests/printf/test.c
+++ b/tests/printf/test.c
@@ -11,9 +11,12 @@ int main() {
printf("Preceding with blanks: %10d %10d\n", 1977, -1977);
printf("Preceding with zeros: %010d %010d\n", 1977, -1977);
printf("Force sign: %+d %+d %+6d %+6d\n", 1977, -1977, 1977, -1977);
+ printf("Force sign or space: % d % d % 6d % 6d\n", 1977, -1977, 1977, -1977);
+ printf("Sign overrides space: % +d % +d % +6d % +6d\n", 1977, -1977, 1977, -1977);
printf("Some different radixes: %d %x %o %#x %#o\n", 100, 100, 100, 100, 100);
printf("floats: %4.2f %+.0e %E %08.2f\n", 3.1416, 3.1416, 3.1416, 3.1416);
printf("negative floats: %4.2f %+.0e %E %08.2f\n", -3.1416, -3.1416, -3.1416, -3.1416);
+ printf("Force sign or space: % .2f % .2f % 6.2f % 6.2f\n", 3.1416, -3.1416, 3.1416, -3.1416);
printf("Width trick: %*d\n", 5, 10);
printf("%s %%\n", "A string");
printf("Null string: %7s\n", NULL);