Using the setw(), setiosflags() classes, ios::showpos and ios::internal methods C++ program sample

 

Compiler: Visual C++ Express Edition 2005

Compiled on Platform: Windows XP Pro SP2

Header file: Standard

Additional library: none/default

Additional project setting: Set project to be compiled as C++

Project -> your_project_name Properties -> Configuration Properties -> C/C++ -> Advanced -> Compiled As: Compiled as C++ Code (/TP)

Other info: none

To do: Using the setw(), setiosflags() classes, ios::showpos and ios::internal methods C++ program sample

To show: How to use the setw(), setiosflags() classes, ios::showpos and ios::internal methods in C++ programming

 

// using the setw(), setiosflags(), showpos and internal

#include <iostream>

#include <iomanip>

using namespace std;

 

void main(void)

{

cout<<setiosflags(ios::internal | ios::showpos)

<<setw(12)<<12345<<endl;

}

 

Output example:

 

+ 12345

Press any key to continue . . .

 

 

C and C++ Programming Resources | C & C++ Code Example Index