Darwin Help

Back to Index

printf

Function printf


Calling Sequence  printf(textpattern, e1, e2,...)
Parameters
NameTypeDescription

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


CharacterDescription
aprints any Darwin value including lists, sets and structures
Asame as a, but will quote strings (same as dprint)
cprints a single character
dprints an integer
eprints a number in exponential notation
fprints a number (decimal notation)
gprints a number (general format, use f or e, whichever is shorter)
eprints a number (explicit exponent)
oprints the octal conversion of an integer
sprints a string (symbol or string)
uprints an unsigned integer
xprints the hexadecimal conversion of an integer
%prints a percent sign %

The cursor control sequences for the printf command:


CharacterDescription
bbackspace
ncarriage return and newline
ttab
vnewline
\\ 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