From 93569fdf640e2c03cee1a92d292ea6c6fc9e73c9 Mon Sep 17 00:00:00 2001 From: mo khan Date: Sun, 20 Jul 2014 19:38:06 -0600 Subject: add format specifiers example. --- fmt_strings.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 fmt_strings.c diff --git a/fmt_strings.c b/fmt_strings.c new file mode 100644 index 0000000..102f42d --- /dev/null +++ b/fmt_strings.c @@ -0,0 +1,19 @@ +#include +#include + +int main(int argc, const char *argv[]) +{ + char string[10]; + int A = -73; + unsigned int B = 31337; + + strcpy(string, "sample"); + + printf("[A] Dec: %d, Hex %x, Unsigned: %u\n", A, A, A); + printf("[B] Dec: %d, Hex %x, Unsigned: %u\n", B, B, B); + printf("[field width on B] 3: '%3u', 10: '%10u', '%o8u'\n", B, B, B); + printf("[string] %s Address %08x\n", string, (unsigned int)string); + + printf("variable A is at address: %08x\n", (unsigned int)&A); + return 0; +} -- cgit v1.2.3