Page 175 - C-Language
P. 175

Flag      Conversions      Meaning

                    numeric          or '-' ). The conversion shall begin with a sign only when a negative
                                     value is converted if this flag is not specified.


                                     If the first character of a signed conversion is not a sign or if a
                    signed           signed conversion results in no characters, a <space> shall be
          <space>
                    numeric          prefixed to the result. This means that if the <space> and '+' flags
                                     both appear, the <space> flag shall be ignored.

                                     Specifies that the value is to be converted to an alternative form.
                                     For o conversion, it shall increase the precision, if and only if
                                     necessary, to force the first digit of the result to be a zero (if the
                                     value and precision are both 0, a single 0 is printed). For x or X
                                     conversion specifiers, a non-zero result shall have 0x (or 0X)
                                     prefixed to it. For a, A, e, E, f, F, g, and G conversion specifiers, the
          #         all
                                     result shall always contain a radix character, even if no digits follow
                                     the radix character. Without this flag, a radix character appears in
                                     the result of these conversions only if a digit follows it. For g and G
                                     conversion specifiers, trailing zeros shall not be removed from the
                                     result as they normally are. For other conversion specifiers, the
                                     behavior is undefined.


                                     For d, i, o, u, x, X, a, A, e, E, f, F, g, and G conversion specifiers,
                                     leading zeros (following any indication of sign or base) are used to
                                     pad to the field width rather than performing space padding, except
                                     when converting an infinity or NaN. If the '0' and '-' flags both
          0         numeric          appear, the '0' flag is ignored. For d, i, o, u, x, and X conversion
                                     specifiers, if a precision is specified, the '0' flag shall be ignored.  If
                                     the '0' and <apostrophe> flags both appear, the grouping characters
                                     are inserted before zero padding. For other conversions, the
                                     behavior is undefined.


        These flags are also supported by Microsoft with the same meanings.


        The POSIX specification for printf() adds:


          Flag   Conversions       Meaning


                                   The integer portion of the result of a decimal conversion shall be
                 i, d, u, f, F, g,   formatted with thousands' grouping characters. For other conversions
          '
                 G                 the behavior is undefined. The non-monetary grouping character is
                                   used.


        Read Formatted Input/Output online: https://riptutorial.com/c/topic/3750/formatted-input-output








        https://riptutorial.com/                                                                             151
   170   171   172   173   174   175   176   177   178   179   180