Skip to content

Commit

Permalink
Add macro with int cast
Browse files Browse the repository at this point in the history
  • Loading branch information
MaJerle committed Sep 27, 2020
1 parent 34d66fc commit 8d501de
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions examples/additional_format_specifiers.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ additional_format_specifiers(void) {
unsigned char my_array[] = { 0x01, 0x02, 0xA4, 0xB5, 0xC6 };

/* Binary output */

/* Prints number 8 in binary format, so "1000" */
lwprintf_printf("%b\r\n", 8U);
/* Prints number 16 in binary format with 10 places, so " 10000" */
Expand All @@ -25,11 +25,11 @@ additional_format_specifiers(void) {
/* Fixed length with lowercase hex numbers, outputs "0102a4b5c6" */
lwprintf_printf("%5k\r\n", my_array);
/* Variable length with uppercase letters, outputs "0102A4B5C6" */
lwprintf_printf("%*K\r\n", sizeof(my_array) / sizeof(my_array[0]), my_array);
lwprintf_printf("%*K\r\n", (int)LWPRINTF_ARRAYSIZE(my_array), my_array);
/* Variable length with lowercase letters, outputs "0102a4b5c6" */
lwprintf_printf("%*k\r\n", sizeof(my_array) / sizeof(my_array[0]), my_array);
lwprintf_printf("%*k\r\n", (int)LWPRINTF_ARRAYSIZE(my_array), my_array);
/* Variable length with uppercase letters and spaces, outputs "01 02 A4 B5 C6" */
lwprintf_printf("% *K\r\n", sizeof(my_array) / sizeof(my_array[0]), my_array);
lwprintf_printf("% *K\r\n", (int)LWPRINTF_ARRAYSIZE(my_array), my_array);
/* Variable length with uppercase letters and spaces, outputs "01 02 a4 b5 c6" */
lwprintf_printf("% *k\r\n", sizeof(my_array) / sizeof(my_array[0]), my_array);
lwprintf_printf("% *k\r\n", (int)LWPRINTF_ARRAYSIZE(my_array), my_array);
}

0 comments on commit 8d501de

Please sign in to comment.