Printing an integer with internal spacing and plus sign : cout « Development « C++ Tutorial

Home
C++ Tutorial
1.Language Basics
2.Data Types
3.Operators statements
4.Array
5.Development
6.Exceptions
7.Function
8.Structure
9.Class
10.Operator Overloading
11.Pointer
12.File Stream
13.template
14.STL Introduction
15.string
16.vector
17.list
18.bitset
19.set multiset
20.valarray
21.queue stack
22.deque
23.map multimap
24.STL Algorithms Modifying sequence operations
25.STL Algorithms Non modifying sequence operations
26.STL Algorithms Binary search
27.STL Algorithms Sorting
28.STL Algorithms Merge
29.STL Algorithms Min Max
30.STL Algorithms Iterator
31.STL Algorithms Heap
32.STL Algorithms Helper
C / ANSI-C
C Tutorial
C++
Visual C++ .NET
C++ Tutorial » Development » cout 
5.2.37.Printing an integer with internal spacing and plus sign
#include <iostream>
using std::cout;
using std::endl;
using std::internal;
using std::showpos;

#include <iomanip>
using std::setw;

int main()
{
   cout << internal << showpos << setw10 << 123 << endl;
   return 0;
}
+      123
5.2.cout
5.2.1.parameterless manipulators that operate on output streams
5.2.2.To use a parameterized manipulator, you must include . It defines the following manipulators:
5.2.3.Using Manipulators to Format I/O
5.2.4.Use std::cout to output message to console
5.2.5.Use std::cout to output various data
5.2.6.Printing a line of text with multiple statements
5.2.7.Use std::endl to output a new line sign
5.2.8.cout: unsetf
5.2.9.Printing multiple lines of text with a single statement: use the \n
5.2.10.Output a pointer
5.2.11.Use function in cout statement
5.2.12.cout: setf()
5.2.13.cout: flags() and unsetf()
5.2.14.cout: width()
5.2.15.cout: precision()
5.2.16.cout: fill()
5.2.17.Using write().
5.2.18.An I/O manipulator: cout << setprecision(2)
5.2.19.An I/O manipulator: cout << setw(20)
5.2.20.use the setiosflags( ) manipulator to directly set the various format flags related to a stream.
5.2.21.cout: setiosflags()
5.2.22.Skip leading whitespace.
5.2.23.Scientific mode; don't show plus sign anymore
5.2.24.Fixed-point mode, show a '+' for positive nums, show 3 digits to the right of the decimal
5.2.25.setiosflags(ios::showpos); and setiosflags(ios::showbase);
5.2.26.ios::showpos | ios::showbase | ios::oct | ios::right
5.2.27.Set cout to output hex
5.2.28.Show default condition of format flags
5.2.29.cout.setf(ios::showpoint | ios::showpos, ios::showpoint);
5.2.30.Set ios::showpoint, ios::showpos for double pointer number
5.2.31.OR together two or more flags
5.2.32.unset flag one by one
5.2.33.cout boolalpha: cause bool values to display as true or false
5.2.34.Demonstrating the flags member function
5.2.35.Using showpoint to control the printing of trailing zeros anddecimal points for doubles
5.2.36.Demonstrating left justification and right justification
5.2.37.Printing an integer with internal spacing and plus sign
5.2.38.Using stream-manipulator showbase to show number base
5.2.39.Stream-manipulator uppercase.
5.2.40.Demonstrating stream-manipulators boolalpha and noboolalpha.
5.2.41.Controlling precision of floating-point values.
5.2.42.Check cout flags
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.