Flags used in conversion specifications in function printf() - C Reference

C examples for Reference:Language Reference

Introduction

FlagMeaning
- (hyphen) It causes the data to be displayed be left justified within its field. Spaces are postfixed to data.
+ It causes a positive or negative sign to be prefixed to a numeric datum. Without this flag, only negative datums are prefixed with sign.
0 (zero) It causes leading zeros to appear instead of leading blanks to fill the extra space. Applies only to numeric datums which are right justified.
' ' (blank space) It causes a blank space to be prefixed to a positive numeric datum. This flag is overridden by + flag, if both flags are present.
# When used with conversion specifications %o and %x, it causes the octal and hexadecimal datums to be preceded by 0 and 0x respectively.
# When used with conversion specifications %f, %e, and %g, it causes a decimal point to be present in all floating-point datums, even if datum is a whole number. It also prevents the truncation of trailing zeros after decimal point in conversion specification %g.

Related Tutorials