Mikroelektronika MIKROE-738 Datenbogen
mikroC PRO for PIC32
MikroElektronika
649
Sprint Library
The mikroC PRO for PIC32 provides the standard ANSI C Sprintf function for easy data formatting.
Note: In addition to ANSI C standard, the Sprint Library also includes two limited versions of the
sprintf
function
(
sprinti
and
sprintl
)
These functions take less ROM and RAM and may be more convenient for use in some cases.
Library Dependency Tree
Functions
- sprintf
- sprintl
- sprinti
sprintf
Prototype
void sprintf(char *wh, const code char *f,...);
Returns
The function returns the number of characters actually written to destination string.
Description
sprintf
is used to format data and print them into destination string.
Parameters:
-
wh:
destination string
-
f:
format string
The
f
argument is a format string and may be composed of characters, escape sequences, and
format specifications. Ordinary characters and escape sequences are copied to the destination string
in the order in which they are interpreted. Format specifications always begin with a percent sign (
%
)
and require additional arguments to be included in the function call.
The format string is read from left to right. The first format specification encountered refers to the
first argument after
f
and then converts and outputs it using the format specification. The second
format specification accesses the second argument after
f
, and so on. If there are more arguments
than format specifications, then these extra arguments are ignored. Results are unpredictable if there
are not enough arguments for the format specifications. The format specifications have the following
format:
% [flags] [width] [.precision] [{ l | L }] conversion_type
Each field in the format specification can be a single character or a number which specifies a particular
format option. The
conversion_type
field is where a single character specifies that the argument is
interpreted as a character, string, number, or pointer, as shown in the following table: