Copyright (C) 2000-2012 |
GNU Info (m4.info)FormatFormatted output ================ Formatted output can be made with `format': format(FORMAT-STRING, ...) which works much like the C function `printf'. The first argument is a format string, which can contain `%' specifications, and the expansion of `format' is the formatted string. Its use is best described by a few examples: define(`foo', `The brown fox jumped over the lazy dog') => format(`The string "%s" is %d characters long', foo, len(foo)) =>The string "The brown fox jumped over the lazy dog" is 38 characters long Using the `forloop' macro defined in Note: Loops, this example shows how `format' can be used to produce tabular output. forloop(`i', 1, 10, `format(`%6d squared is %10d ', i, eval(i**2))') => 1 squared is 1 => 2 squared is 4 => 3 squared is 9 => 4 squared is 16 => 5 squared is 25 => 6 squared is 36 => 7 squared is 49 => 8 squared is 64 => 9 squared is 81 => 10 squared is 100 The builtin `format' is modeled after the ANSI C `printf' function, and supports the normal `%' specifiers: `c', `s', `d', `o', `x', `X', `u', `e', `E' and `f'; it supports field widths and precisions, and the modifiers `+', `-', ` ', `0', `#', `h' and `l'. For more details on the functioning of `printf', see the C Library Manual. automatically generated by info2www version 1.2.2.9 |