!--a11y-->
Purpose
Returns a string using the specified formatting.
Syntax
string printf (in string format,...)
Parameters
format |
Format string (template) from which to create the final string. The format string contains "%" format specifiers that are replaced by parameters passed as the...-arguments. The number of arguments is variable. |
Description
This function returns a string built from the given format string by resolving format specifiers from a given variable argument list (like the
printf() function in C).Format specifiers have the following form:
%<flags><width><.pre><conversion>
where:<flags> can contain zero or more of: |
- |
Left justify within field. |
+ |
Display leading sign. | |
<space> |
Prefix space to result instead of sign. | |
0 |
Leading zeros. | |
<width> |
Number of characters to expand to (optional). | |
<pre> |
Precision to use for (optional after.). | |
diouxX |
Minimum number of digits. | |
s |
Maximum number of chars. | |
<conversion> contains one of: |
% |
"%" character |
d |
Signed decimal integer | |
I |
Signed integer | |
u |
Unsigned decimal integer | |
x, X |
Unsigned hexadecimal integer | |
o |
Unsigned octal character | |
c |
Display as character | |
s |
String |
Return Value
Returns a string constructed from the format string by replacing all "%" format specifiers.
Example
`printf ("Lawrence Smith", format="%-20s will be opening %s in %s on %s %02d, %04d.",
"a menswear store", "Billingsley", "January", 1, 1999)`
