[an error occurred while processing this directive]

HP OpenVMS Systems

C Programming Language
Content starts here

Optional_character

flags You can use the following flag characters, alone or in any combined order, to modify the conversion specification: ' Requests that a numeric conversion is formatted with the thousands separator character. Only the numbers to the left of the radix character are formatted with the separator character. The character used as a separator and the positioning of the separators are defined in the program's current locale. -(hyphen) Left-justifies the converted output source in its field. + Requests that an explicit sign be present on a signed conversion. If this flag is not specified, the result of a signed conversion begins with a sign only when a negative value is converted. space Prefixes a space to the result of a signed conversion, if the first character of the conversion is not a sign, or if the conversion results in no characters. If you specify both the space and the + flag, the space flag is ignored. # Requests an alternate form conversion. Depending on the conversion specified, different actions will occur. For the o (octal) conversion, the precision is increased to force the first digit to be a 0. For the x (or X) conversion, a nonzero result is prefixed with 0x (or 0X). For e, E, f, g, and G conversions, the result contains a decimal point even at the end of an integer value. For g and G conversions, trailing zeros are not trimmed. For other conversions, the effect of # is undefined. 0 Uses zeros rather than spaces to pad the field width for d, i, o, u, x, X, e, E, f, g, and G conversions. If both the 0 and the - flags are specified, then the 0 flag is ignored. For d, i, o, u, x, and X conversions, if a precision is specified, the 0 flag is ignored. For other conversions, the behavior of the 0 flag is undefined. field width The minimum field width can be designated by a decimal integer constant, or by an output source. To specify an output source, use an asterisk (*) or the sequence *n$, where n refers to the nth output source listed after the format specification. If the converted output source is wider than the minimum field, write it out. If the converted output source is narrower than the minimum width, pad it to make up the field width. Pad with spaces, by default. Pad with zeros if the 0 flag is specified; this does not mean that the width is an octal number. Padding is on the left by default, and on the right if a minus sign is specified. period (.) Separates the field width from the precision. precision The precision defines the minimum number of digits to appear for d, i, o, u, x, and X conversions; the number of digits to appear after the decimal-point character for e, E, and f conversions; the maximum number of significant digits for g and G conversions; or the maximum number of characters to be written from a string in an s or S conversion. If a precision appears with any other conversion specifier, the behavior is undefined. Precision can be designated by a decimal integer constant, or by an output source. To specify an output source, use an asterisk (*) or the sequence *n$, where n refers to the nth output source listed after the format specification. If only the period is specified, the precision is taken as 0. h, l, or L An h specifies that a following d, i, o, u, x, or X conversion specifier applies to a short int or unsigned short int argument; an h can also specify that a following n conversion specifier applies to a pointer to a short int argument. An l (lowercase ell) specifies that a following d, i, o, u, x, or X conversion specifier applies to a long int or unsigned long int argument; an l can also specify that a following n conversion specifier applies to a pointer to a long int argument. An L specifies that a following e, E, f, g, or G conversion specifier applies to a long double argument. If an h, l, or L appears with any other conversion specifier, the behavior is undefined. On Compaq C for OpenVMS VAX and Alpha Systems, int values are equivalent to long values.

Conversion_Specifier

d, i Converts an int argument to signed decimal format. o Converts an unsigned int argument to unsigned octal format. u Converts an unsigned int argument to unsigned decimal format (giving a number in the range 0 to 4,294,967,295). x, X Converts an unsigned int argument to unsigned hexadecimal format (with or without a leading 0x). The letters 'abcdef' are used for the x conversion; the letters 'ABCDEF' are used for the X conversion. f Converts a float or double argument to the format [-]mmm.nnnnnn. The number of n's is equal to the precision specification. If no precision is specified, the default is 6. If the precision is 0 and the # flag is specified, the decimal point appears but no n's appear. If the precision is 0 and the # flag is not specified, the decimal point also does not appear. If a decimal point appears, at least one digit appears before it. The value is rounded to the appropriate number of digits. e, E Converts a float or double argument to the format [-]m.nnnnnnE[+|-]xx. The number of n's is specified by the precision. If no precision is specified, the default is 6. If the precision is explicitly 0 and the # flag is specified, the decimal point appears but no n's appear. If the precision is explicitly 0 and the # flag is not specified, the decimal point also does not appear. An 'e' is printed for e conversion; an 'E' is printed for E conversion. The exponent always contains at least two digits. If the value is 0, the exponent is 0. g, G Converts a float or double argument to format f or e (or E if the G conversion specifier is used), with the precision specifying the number of significant digits. If the precision is 0, it is taken as 1. The format used depends on the value of the argument: format e (or E) is used only if the exponent resulting from such a conversion is less than -4, or is greater than or equal to the precision; otherwise, format f is used. Trailing zeros are suppressed in the fractional portion of the result. A decimal point appears only if it is followed by a digit. c Converts an int argument to an unsigned char, and writes the resulting character (null characters are ignored). C Converts a wchar_t argument to an array of bytes representing the character, and writes the resulting character. If the field width is specified and the resulting character occupies fewer bytes than the field width, it will be padded to the given width with space characters. If the precision is specified, the behavior is undefined. s Requires an argument that is a pointer to an array of characters of type char. The argument is used to write characters until a null character is encountered or until the number of characters indicated by the precision specification is exhausted. If the precision specification is 0 or omitted, all characters up to a null are output. S Converts an array of wide-character codes to multibyte characters, and writes the multibyte characters. Requires an argument that is a pointer to an array of wide characters of type wchar_t. Characters are written until a null wide character is encountered or until the number of bytes indicated by the precision specification is exhausted. If the precision specification is omitted or is greater than the size of the array of converted bytes, the array of wide characters must be terminated by a null wide character. p Requires an argument that is a pointer to void. The value of the pointer is output as a hexadecimal character. n Requires an argument that is a pointer to an integer. The integer is assigned the number of characters written to the output stream so far by this call to the formatted output function. No argument is converted. % Writes out the percent symbol. No conversion is performed. The complete conversion specification would be %%.