English
Language : 

CC78K4 Datasheet, PDF (178/523 Pages) NEC – CC78K4 Ver.2.30 or Later, C Compiler Language
CHAPTER 10 LIBRARY FUNCTIONS
4-1 sprintf
I/O Functions
FUNCTION
sprintf writes data into a character string according to the format.
HEADER
stdio.h
FUNCTION PROTOTYPE
int sprintf (char *s,const char *format,...);
Function
sprintf
Arguments
s ... Pointer to the string into
which the output is to be
written
format ... Pointer to the string
that indicates format
commands
... ... Zero or more arguments
to be converted
Return Value
Number of characters written
in s (Terminating null
character is not counted.)
EXPLANATION
• If there are fewer actual arguments than the formats, the proper operation is not guaranteed. If the formats run
out despite the fact that actual arguments still remain, the excess actual arguments are only evaluated and
ignored.
• sprintf converts zero or more arguments that follow format according to the format command specified by
format and writes (copies) them into the string s.
• Zero or more format commands may be used. Ordinary characters (other than format commands that begin
with a % character) are output as is to the string s. Each format command takes zero or more arguments that
follow format and outputs them to the string s.
• Each format command begins with a % character and is followed by these:
• Zero or more flags (to be explained later) that modify the meaning of the format command
• Optional decimal integer that specifies a minimum field width
If the output width after the conversion is less than this minimum field width, this specifier pads the output
with spaces or zeros on its left. (If the left-justifying flag “−” (minus) sign follows %, zeros are padded out
to the right of the output.)
The default padding is done with spaces. If the output is to be padded with 0s, place a 0 before the field
width specifier. If the number or string is greater than the minimum field width, it will be printed in full
even if the minimum is exceeded.
• Optional precision (number of decimal places) specification (. integer)
With d, i, o, u, x, and X type specifiers, the minimum number of digits is specified. With the s type
specifier, the maximum number of characters (maximum field width) is specified. The number of digits to
be output following the decimal point is specified for e, E, and f conversions. The number of maximum
effective digits is specified for g and G conversions. This precision specification must be made in the
form of (.integers). If the integer part is omitted, 0 is assumed to have been specified. The amount of
padding resulting from this precision specification takes precedence over the padding by the field width
specification.
178
User’s Manual U15556EJ1V0UM