beautypg.com

Function, see the, Printf flag characters – Zilog Z8F0130 User Manual

Page 477

background image

UM013037-1212

printf

Zilog Developer Studio II – Z8 Encore!

User Manual

453

Synopsis

#include

int printf(char *format, ...);

Returns

The number of characters transmitted or a negative value if an output error occurred.

Example

int i=10;

printf("This is %d",i);

By default, Zilog compilers parse

printf

and

sprintf

format strings and generate calls

to lower level support routines instead of generating calls to

printf

and

sprintf

. For

more information, see the description of the

-genprintf

option in the

Generate Printfs

Inline

section on page 84.

The UART must be initialized using the Zilog

init_uart()

function. See the

init_uart

section on page 232.

printf Flag Characters

-

The result of the conversion is left-justified within the field.

+

The result of a signed conversion always begins with a plus or a minus sign.

space If the first character of a signed conversion is not a sign, a space is added before

the result. If the space and + flags both appear, the space flag is ignored

#

The result is to be converted to an ''alternate form''. For c, d, i, s, and u
conversions, the flag has no effect. For o conversion, it increases the precision to
force the first digit of the result to be a zero. For x (or X) conversion, a nonzero
result always contains a decimal point, even if no digits follow the point (normally,
a decimal point appears in the result of these conversions only if a digit follows it).
For g and G conversions, trailing zeros are not removed from the result, as they
normally are.

Note: