diff options
| author | mo khan <mo@mokhan.ca> | 2014-07-20 19:38:06 -0600 |
|---|---|---|
| committer | mo khan <mo@mokhan.ca> | 2014-07-20 19:38:06 -0600 |
| commit | 93569fdf640e2c03cee1a92d292ea6c6fc9e73c9 (patch) | |
| tree | a5614e5b476e5728f4c9239c000196b37cdd6db4 | |
| parent | 0aaeaeded242eb127f0e1059c9295fa082ea3672 (diff) | |
add format specifiers example.
| -rw-r--r-- | fmt_strings.c | 19 |
1 files changed, 19 insertions, 0 deletions
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 <stdio.h> +#include <string.h> + +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; +} |
