Friday, January 6, 2012

Manipulator, setw()

Examples of using setw():
Manipulator, setw()
// ConsoleApplication1.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include <iostream>
#include <iomanip>

using namespace std;

int _tmain(int argc, _TCHAR* argv[])
{
 cout << "Usage of setw(6): " << endl;
 cout << setw(6) << 1234 << endl;
 cout << setw(6) << 1234567890 << endl;
 cout << setw(6) << 0.1 << endl;
 cout << setw(6) << "abc" << endl;
 cout << setw(6) << "abcdefghijklmn" << endl;
 cout << setw(6) << 12.3456789 << endl;
 cout << setw(6) << 123456789.0 << endl;
 cout << setw(6) << 'a' << endl ;

 system("PAUSE");
 return 0;
}


No comments:

Post a Comment