It seems like the browser you are using has JavaScript disabled. As a result, the site will not function properly. We really want you to enable it so you may experience our site as we intended it. If you have no idea what we are talking about or if you need help, visit http://www.enable-javascript.com×
This website uses cookies. By continuing to browse this site you are agreeing to our use of cookies. Find out more on our cookie page.×

Oops, it seems like you're using an old browser that we do not fully support. If you're able to, please upgrade your browser here.×
This website uses cookies. By continuing to browse this site you are agreeing to our use of cookies. Find out more on our cookie page.×

Several library functions help you convert data values from
encoded internal representations to text sequences that are
generally readable by people. You provide a
format string as the value of the
format argument to each of these functions, hence
the term formatted output.
The functions fall into two categories.

A print function scans the format string once from beginning
to end to determine what conversions to perform. Every print
function accepts a
varying number
of arguments, either directly or under control of an argument of type
va_list.
Some print conversion specifications
in the format string use the next argument in the list.
A print function uses each successive argument no more than
once. Trailing arguments can be left unused.

For the print functions, literal text or
white space in a format
string generates characters that match the characters in the format
string. A
print conversion specification typically generates characters
by converting the next argument value to a corresponding text sequence.
A print conversion specification has the format:

Boldface Italic indicates a feature added after
C99.
Support for fixed-point conversions is added with
the C Technical Report TR18037.
These closely match the extensions for the Freescale
Signal Processing Engine Auxiliary Processing Unit.
This implementation
also includes, as a conforming extension, conversions for
the vectors supported by the Freescale
AltiVec architecture.

Following the percent character (%)
in the format string, you can write zero or more
format flags:

-
-- to left-justify a conversion

+
-- to generate a plus sign for signed values that
are positive

space
-- to generate a space for signed values
that have neither a plus nor a minus sign

#
-- to prefix 0 on an o conversion,
to prefix 0x on an x conversion,
to prefix 0X on an X conversion,
or to generate a decimal point and fraction
digits that are otherwise suppressed on a floating-point conversion

0
-- to pad a conversion with leading zeros after
any sign or prefix, in the absence of a minus (-)
format flag or a specified precision

For AltiVec vector conversions,
you can intersperse format flags with an optional
separator, the characters
comma, semicolon, equal sign, or underscore. The conversion
occurs for each of the elements of the vector, and
generates a separator between each pair of elements.
If you specify no separator, the default is:

for the c conversion specifier, no character.

for all other conversion specifications, a space character.

Following any format flags, you can write a
field width that
specifies the minimum number of characters to generate for the conversion.
Unless altered by a format flag,
the default behavior is to pad a short conversion
on the left with space characters.
If you write an asterisk (*)
instead of a decimal number for a field width, then a print
function takes the value of the next argument (which must be of type
int) as the field width. If the argument value is negative,
it supplies a - format flag
and its magnitude is the field width.

Following any field width, you can write a dot (.)
followed by a
precision
that specifies one of the following:
the minimum number of digits to generate on an integer conversion;
the number of fraction digits to generate on an e,
E, or f conversion;
the maximum number of significant digits to generate
on a g or G conversion; or the maximum number
of characters to generate from a
C string
on an s conversion.

If you write an * instead of
a decimal number for a precision,
a print function takes the value of the next argument (which must
be of type int) as the precision. If the argument value is
negative, the default precision applies. If you do not write either
an * or a decimal number following the dot, the precision
is zero.

Following any
precision,
you must write a one-character print conversion specifier,
possibly preceded by a one- or two-character qualifier.
Each combination determines the type required of the
next argument (if any) and how the library functions alter the argument
value before converting it to a text sequence.
The integer and
floating-point conversions also determine
what base to use for the text representation.
If a conversion specifier requires a precision p and you do
not provide one in the format, then the conversion specifier chooses
a default value for the precision.

In the descriptions that follow, array declarations for arguments
are not to be taken literally. A declaration of the form:

short x[8]

is shorthand for:

struct {short x[8]; }

And a cast of the form:

(short x[8])x

is shorthand for:

*(struct {short x[8]; } *)&x

The following table lists all defined combinations
and their properties:

The print conversion specifier determines any behavior not summarized
in this table. For all floating-point conversions:

Positive infinity prints as inf or INF.

Negative infinity prints as -inf or -INF.

Not-a-number (NaN) prints as nan or NAN.

The upper-case version prints only for an upper-case conversion specifier,
such as %E but not %Lg.

In the following descriptions, p is the precision.
Examples follow each of the print conversion specifiers.
A single conversion can generate up to 509 characters.

You write %a or
%A to generate
a signed hexadecimal fractional representation with
a decimal power-of-two exponent. The generated text takes the form
±0Xh.hhhP±dd, where ± is either a plus or
minus sign,
X is either x (for %a conversion)
or X (for %A conversion),
h is a hexadecimal digit,
d is a decimal digit, the hexadecimal point (.)
is the decimal point for the current
locale,
and P is either p (for %a conversion)
or P (for %A conversion).
The generated text has one integer digit
which is zero only for the value zero,
a hexadecimal point if any fraction digits are present
or if you specify the #
format flag, at most p fraction digits with no trailing zeros,
and at least one exponent digit with no leading zeros.
The result is rounded. The value zero has a zero exponent.

For a
wide stream,
conversion of the character x occurs as if by calling
btowc(x).

wprintf(L"%c", 'a') generates btowc(a)

You write %lc
to generate a single character from the converted value.
Conversion of the character x occurs as if
it is followed by a null character in an array of two elements of type
wchar_t
converted by the conversion specification
ls.

printf("%lc", L'a') generates a
wprintf(L"lc", L'a') generates L'a'

You write %d,
%i,
%o,
%u,
%x, or
%X to generate
a possibly signed integer representation. %d or %i
specifies signed decimal representation, %o
unsigned octal, %u unsigned decimal,
%x unsigned hexadecimal using the digits 0-9
and a-f, and %X unsigned
hexadecimal using the digits 0-9 and A-F.
The conversion generates at least p digits
to represent the converted value. If p is zero,
a converted value of zero generates no digits.

You write %e or
%E to generate
a signed decimal fractional representation with
a decimal power-of-ten exponent. The generated text takes the form
±d.dddE±dd, where ± is either a plus or
minus sign, d is a decimal digit, the decimal point (.)
is the decimal point for the current
locale,
and E is either e (for %e conversion)
or E (for %E conversion).
The generated text has one integer digit,
a decimal point if p is nonzero or if you specify the #
format flag, p fraction digits, and at least two exponent digits.
The result is rounded. The value zero has a zero exponent.

You write %f%F,
%k,
%K,
%r,
or %R
to generate a signed decimal fractional representation
with no exponent. The generated text takes the form ±d.ddd,
where ± is either a plus or minus sign,
d is a decimal digit, and the decimal point (.)
is the decimal point for the current
locale.
The generated text has at least one integer digit,
a decimal point if p is nonzero or if you specify
the # format flag, and p fraction digits.
The result is rounded.

You write %g or
%G to generate
a signed decimal fractional
representation with or without a decimal power-of-ten exponent, as appropriate.
For %g conversion, the generated text
takes the same form as either %e
or %f conversion. For %G conversion,
it takes the same form as either
%E or
%F
conversion.
The precision p specifies the number
of significant digits generated. (If p is zero, it is changed
to 1.) If %e conversion would yield an exponent in the range
[-4, p), then %f conversion occurs instead.
The generated text has no trailing zeros
in any fraction and has a decimal point
only if there are nonzero fraction digits, unless you specify the
# format flag.

For a
wide stream, conversion
occurs as if by repeatedly calling
mbrtowc,
beginning in the
initial conversion state.
The conversion generates no more than p characters,
up to but not including the terminating null character.

wprintf(L"%s", "hello") generates hello

You write %ls
to generate a sequence of characters from
the values stored in the argument
wide-character string.
For a byte stream,
conversion occurs as if by repeatedly calling
wcrtomb, beginning in the
initial conversion state,
so long as complete multibyte characters can be generated.
The conversion generates no more than
p characters, up to but not including the terminating null
character.

1. Choose your focus

This is the focus controller. Use this controller to choose your primary development approach (Cascades or Core).

By selecting a focus, you get to decide what content should be front and center on the site.

2. Download the tools

Before you start developing, you'll need to visit the Downloads tab. Here you'll find downloads for the BlackBerry 10 Native SDK, BlackBerry 10 Device Simulator, and some other useful tools.

3. Try the sample apps

Now featuring a filter control, the Sample apps tab allows you to search for samples by name or by feature.

Select either the Core or Cascades check boxes to display the samples relevant to your focus.

4. Educate yourself

The Documentation tab contains tons of examples, tutorials, and best practices to guide you along the path towards building an awesome app.

The documentation for your preferred focus always appears at the top of the left-hand navigation, but you can still access the rest of the documentation at the bottom.

5. Start developing

The Reference tab is where you'll find essential details about how to use our APIs.

You can use the left-hand navigation to choose how you would like to browse the reference: by module, by topic, or alphabetically. If you have an idea of what you are looking for, start typing it in the Filter box.