Wednesday, August 19, 2009

Manipulating the output

For different purposes we may need to manipulate the output in the screen. In C++ a particular header file is given where the manipulating functions are defined. So the first step is to include this header file at the beginning of the code file:

#include  <iomanip>

The most important format manipulators are in the following table but not discussed in detail:

setw(width) Display the next value in the field of size width
left Display values left justified within a field when the value printed needs less space than the width of the field.
right Like left but the value are displayed right justified (default)
setprecision(p) Display p fractional digits for all subsequent output of real values.
fixed Use fixed point notation for real values (with p number of digits)



Previous post

Next post




No comments:

Post a Comment