C++ cout Formatting Numbers for Program Output

Introduction

ostream Class Functions

Method Comment Example
precision(n) Equivalent to setprecision()cout.precision(2)
fill('x')Equivalent to setfill() cout.fill('*')
setf(ios::fixed) Equivalent to cout.setf(ios::fixed) setiosflags(ios::fixed)
setf(ios::showpoint) Equivalent to cout.setf(ios::showpoint) setiosflags(ios::showpoint)
setf(ios::left) Equivalent to left cout.setf(ios::left)
setf(ios::right) Equivalent to right cout.setf(ios::right)
setf(ios::flush) Equivalent to endl cout.setf(ios::flush)



PreviousNext

Related