{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

lect03_Formatting

lect03_Formatting - Output Formatting Output Formatting...

Info iconThis preview shows pages 1–6. Sign up to view the full content.

View Full Document Right Arrow Icon
Output Formatting CSIS1117 Computer Programming CS S Co pute og a g 1 c1117 lecture 3
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Content Output Formatting c1117 lecture 3 2
Background image of page 2
Formatting your Output There are 4 parts in an output field: width – width of the field fill – fill character usually blank fill – fill character, usually blank flag – how to format precision number of significant figures precision – number of significant figures. c1117 lecture 3 3
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
width and fill To set the width and fill, use the function To set the width and fill, use the function cout.width() and cout.fill() function E g E.g. cout.width(4); //min 4 chars used fill(’#’) //fill h i i cout.fill(’#’); //fill the remaining space with # cout << ”ab”; cout << ab ; The output is ## b ##ab c1117 lecture 3 4
Background image of page 4
The default fill character is space (blank). The default size is 0 (meaning as many char as needed) needed). If the output is longer than the field width, then th t l l th i t t the actual length is output.
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Image of page 6
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}