Guardian C Library Calls Reference Manual

fprintf
3-52 128833Guardian TNS C Library Calls Reference Manual
Reference to Library Calls
precision is an optional decimal number that specifies the precision used when
formatting the converted value. How fprintf uses this number depends upon the
conversion code that follows it:
For codes d, i, o, u, x, and X, precision is the minimum number of digits to
print.
For codes e, E, and f, precision is the number of digits to print following the
decimal point.
For codes g and G, precision is the maximum number of significant digits.
For code s, precision is the maximum number of characters to print from the
string.
Note that a period precedes the number. If you omit the number (but include the
period), fprintf uses zero as the precision. Also note that the precision value
overrides the field width if the field width cannot accommodate the specified
precision.
modifier is an optional modifier that affects how fprintf interprets the value
being formatted.
conv_code is a conversion code that specifies the interpretation and default
formatting of the value being formatted.
Conversion Flags
Here are the possible values of flags in a conversion specifier:
- Is the left-justify flag; it causes fprintf to pad a converted value on the
right so that it is left justified within its field.
+ Is the sign flag; it causes fprintf to print a plus sign (+) preceding a
positive value in a signed conversion.
blank (a blank character, “ ”) Is the blank flag; it causes fprintf to print a blank
preceding a positive value in a signed conversion. If you use both the sign
flag and the blank flag, fprintf ignores the blank flag.
# Is the alternate-form flag; it causes fprintf to format the converted value
specially, based upon the conversion code:
For code o, this flag causes fprintf to increase the precision so that the
first digit of the converted value is zero.
For codes x and X, this flag causes fprintf to prefix a nonzero
converted value with 0x or 0X, respectively.
For codes e, E, f, g, and G, this flag causes fprintf to include a decimal
point in the converted value, even if there are no fractional digits;
trailing zeros are not removed if the code is g or G.