Pages

100 Contemporary Living Room Designs

Friday, August 10, 2012

MANIPULATOR FUNCTIONS - SETW() AND SETFILL()


C++ Program  to describe the working of setw() and setfill() functions.



#include<iostream.h>
#include<conio.h>
#include<iomanip.h>
void main()
{
  clrscr();
  cout<<setw(5)<<5<<endl;
  cout<<setfill('0')<<setw(5)<<5<<endl;
  cout<<setw(5)<<setfill('0')<<5<<endl;
  cout<<setfill('0')<<setw(5)<<55<<endl;
  cout<<setfill('0')<<setw(5)<<555<<endl;
  getch();
}

output 

 

setw(length); - sets the width of the field assigned for the output.
setfill(char); - used to fill spaces when results have to be padded to the field width
Both functions are defined in the header iomanip.
 

No comments:

Post a Comment