|ARM Technical Support Knowledge Articles|
Applies to: C51 C Compiler
Information in this article applies to:
I can get the printf command to work with integers but not long integers or 8-bit integers. Why?
You must use the optional characters B or b and L or l immediately preceding the type character to respectively specify char or long versions of the integer types d, i ,u, o, x and X.
The following printf correctly prints 1, 2, and 3 as integers:
printf ("%d %d %d", (int) 1, (int) 2, (int) 3);
The following printf correctly prints 1, 2, and 3 as long integers:
printf ("%Ld %Ld %Ld", 1L, 2L, 3L);
The following printf correctly prints 1, 2, and 3 as chars:
printf ("%Bd %Bd %Bd", (char) 1, (char) 2, (char) 3);
The type casts on the numeric constants are important because they specify the number of bytes required for each numeric constant.
Article last edited on: 2004-05-05 20:34:23
Did you find this article helpful? Yes No
How can we improve this article?