The printf procedure creates a character string by formatting the supplied arguments according to the formatting commands in a format control string. The resulting character string is written to the user’s terminal.
The format control string controls the generation of the character string that is written to the user’s terminal. It consists of two types of information: actual content and format command characters. The format command characters are used to insert and format the supplied arguments. The number of format command characters in the format control string must match the number of supplied arguments. In other words, if there are three formatting commands in the format control string, then three function arguments are needed. Otherwise, an error is generated.
For more information on format command characters, please see Other Programming Considerations.
printf (controlstring [,arugment1, …]);
|controlstring||Required. Character string that contains the format control string that is used to generate the formatted string that is returned in result|
|argument1 …||Optional. Character strings and/or integer values to substitute into the formatted string|
Because printf is a procedure, no return value is set.
In this example,
printf ("System administrator Ids: %s %s %s\n", "JWhite", "TWhitman", "EPipes");
the following string is printed:
System administrator Ids: JWhite TWhitman EPipes
fprintf, outputredirect, print, sprint(), syslog