printf Flag Characters

Top 

 

The Flag characters can appear in any order and combination.

Flag

   Description

 

-

   Left-justifies the result, pads on the right with blanks. If not given, it right-justifies the result, pads on the left with zeros or blanks.

+

   Signed conversion results always begin with a plus (+) or minus (-) sign.

blank

   If value is nonnegative, the output begins with a blank instead of a plus; negative values still begin with a minus.

#

   Specifies that arg is to be converted using an alternate form.

Note. Plus (+) takes precedence over blank () if both are given