printf() style format string

Displays formatted text.

Show/hideSyntax

printf format_string

where:

format_string

Is a format specification.

Show/hideDescription

The printf command uses a special format string to output text and numbers. If you are using Eclipse for DS-5, then you can use the set print double-format and set print float-format commands to control the formatting of values. It works in a similar way to the ANSI C standard library function printf().

Show/hideFormat string syntax

The message in format_string is a string. If there are no % characters in the string, the message is written out and any arguments are ignored. The % symbol is used to indicate the start of an argument conversion specification.

The syntax of the specification is:

%[flag...][fieldwidth][precision]format

where:

flag

An optional conversion modification flag.

"-"

result is left-justified

"#"

result uses a conversion-dependent alternate form

"+"

result includes a sign

" "

result includes a leading space for positive values

"0"

result is zero-padded

","

result includes locale-specific grouping separator

"("

result encloses negative numbers in parentheses.

fieldwidth

An optional minimum field width specified in decimal.

precision

An optional precision specified in decimal, with a preceding . (period character) to identify it.

format

The possible conversion specifier characters are:

%

A literal % character.

a, A, e, E, f, g, or G

Results in a decimal number formatted using scientific notation or floating point notation. The capital letter forms use a capital E in scientific notation rather than an e.

d,or u

Results in a decimal integer. d indicates a signed integer. u indicates an unsigned integer.

h, H

Results in a Hexadecimal character in lower or upper case.

x or X

Results in an unsigned Hexadecimal character in lower or upper case.

o

Results in an octal integer.

c or C

Results in a Unicode character in lower or upper case.

s

Results in a string.

b or B

Results in a string containing either "true" or "false" in lower or upper case.

n

Results in a platform-specific line separator.

t or T

Prefix for date and time conversion specifier characters. For example:

"%ta %tb %td %tT" results in "Sun Jul 20 16:17:00"

Show/hideSee also

Copyright © 2010-2012 ARM. All rights reserved.ARM DUI 0452J
Non-ConfidentialID051612