| Calling Sequence
| printf(textpattern, e1, e2,...)
|
| Parameters
| | Name | Type | Description |
|
| textpattern
| string | |
| ei
| expression | |
|
| Return Type
| NULL |
| Synopsis
| The printf statement behaves in a similar manner as C's
printf statement. |
| Conversion characters for the printf co
|
| | Character | Description |
| a | prints any Darwin value including lists, sets and structures |
| A | same as a, but will quote strings (same as dprint) |
| c | prints a single character |
| d | prints an integer |
| e | prints a number in exponential notation |
| f | prints a number (decimal notation) |
| g | prints a number (general format, use f or e, whichever is shorter) |
| e | prints a number (explicit exponent) |
| o | prints the octal conversion of an integer |
| s | prints a string (symbol or string) |
| u | prints an unsigned integer |
| x | prints the hexadecimal conversion of an integer |
| % | prints a percent sign % |
|
| The cursor control sequences for the printf command:
|
| | Character | Description |
| b | backspace |
| n | carriage return and newline |
| t | tab |
| v | newline |
| \\ | single backslash |
| '' | single quote |
|
| Examples
| > printf('%a, %a\n', ['L', 'I', 'S', 'T'],
'a means any structure');
[L, I, S, T], a means any structure
> int := 1234;
int := 1234
> printf('|%d|%10d|%-10d|\n', int, int, int, int);
|1234| 1234|1234 |
> t := 1234.567;
t := 1234.5670
> printf('|%f|%12f|%12.5f|%-12.5f|\n', t, t, t, t);
|1234.567000| 1234.567000| 1234.56700|1234.56700 |
> printf('|%11s|%12s|%12s|%12s|\n', 'normal',
'field of 12', '5 decimal', 'left flush');
| normal| field of 12| 5 decimal| left flush|
|
| See also
| lprint, print, prints, sprintf, sscanf |