printf
Notes
- reference
- We will be using printf for some of our output.
- This is part of the C library (so in c++ as well)
- There are multiple versions of it printf, fprintf, sprintf
- We only want printf for now.
- This is a variable argument function
- The first argument is always a format string
- Then for each conversion specifier in that format string an additional parameter is required.
- Conversion specifiers
- The character %
- optional :
- - : justifies left, right justification is default
- + : show the sign, negative numbers always have a sign
- space: put a space place of the -, ignored for +
- # : use an alternative output format
- 0: pad with 0
- optinal minimum field width n
- .n optional precision for floating point types
- conversion specifier
- The chart on the reference page is helpful.
- Some examples