Next: Pretty Print a Square
Up: Printing Routines
Previous: Pretty Print
Calling Sequence:
printf(
textpattern,
)
Parameters:
Synopsis:
The printf statement behaves in a similar manner as C's printf statement.
Table:
Conversion characters for the printf command.
1.1
Table:
Conversion characters for the printf command.
Character |
Description |
a |
prints any Darwin value including lists and sets |
c |
prints a single character |
d |
prints an integer |
e |
prints a number in exponential notation |
f |
prints a real number |
g |
prints a real number in the same manner as the |
|
e character if the exponent is greater than 8. |
|
Otherwise equivalent to the f or d character. |
o |
prints the octal conversion of an integer |
s |
prints out an item of type name |
u |
prints an unsigned integer |
x |
prints the hexadecimal conversion of an integer |
% |
prints a percent sign % |
|
Table:
The cursor control sequences for the printf command.
1.1
Table:
The cursor control sequences for the printf command.
Character |
Description |
\b |
backspace |
\n |
carriage return |
|
and newline |
\t |
tab |
\v |
newline |
\\ |
\ |
\'' |
' |
|
Examples:
> printf('%a, %a', ['L', 'I', 'S', 'T'], 'a means any structure');
> int := 1234;
> printf('\n|%d|%10d|%-10d|', int, int, int, int); # integers
> real := 1234.567;
printf('\n|%11s|%12s|%12s|%12s|', 'normal', 'field of 12', '5 decimal', 'left flush');
printf('\n|%f|%12f|%12.5f|%-12.5f|', real, real, real, real);
See also: print, lprint
Next: Pretty Print a Square
Up: Printing Routines
Previous: Pretty Print
Gaston Gonnet
1998-09-15