C + + iostream

Source: Internet
Author: User

Ext.: http://blog.csdn.net/ouczoe/article/details/4923413

The input and output stream is defined in <iostream> and the standard console output stream is also declared in this header file cout

Header file with control: standard header file <ios> and <iomanip>

Output stream:

Boolalpha and Noboolalpha: notifies the output stream to output bool as true and False (Boolalpha) or 1 and 0 (noboolalpha). The default is Noboolalpha.

Hex,oct,dec: 16 binary, 8 binary, 10 binary output digits respectively.

Setprecision: Sets the number of decimal places to output decimals (several after the decimal point). For example, Setprecision (5)--Take 5 digits after the decimal point.

SETW: Sets the width of the field when outputting numeric data. e.g. SETW (5).

Setfill: When the width of the number is less than the width of the set, the control can make the characters that fill the empty space. Setfill (' a ').

Showpoint and Nonshowpoint: for floating-point or double-precision numbers without fractional parts, this control forces the flow to always display decimals or not display decimals.

Endl: Encapsulates data and behavior. The number of notification flows outputs a carriage return and refreshes its buffer output.

These controls are written in front of the output parameters that need to function, such as COUT<<SETW (7) <<setfill (' & ') <<variable<<endl;

e.g. #include <iostream>

#include <iomanip>

using namespace Std;

int main (int argc, char** argv)

{

bool Testb = true;

cout<< "This is a testing of bool" <<boolalpha<<testB<<endl;

}

Input stream:

Boolalpha and Noboolalpha: the string True,false interpreted as Boolean true and False for input save (boolalpha). Noboolalpha won't explain that. The default is Noboolalpha.

Hex,oct,dec: The numbers are read in 16, 8, and 10 respectively.

Skipwa and Noskipwa: The notification flow ignores whitespace characters when doing lexical analysis or reads whitespace into tokens as a whitespace character.

WS: Traverse the control character. Ignores a string of whitespace at the current position in the stream.

C + + iostream

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.