In C + + format the input and output (formatted and output) detailed

Source: Internet
Author: User
Tags bool reset

Formatted input and output, is in the <iostream> header file, control format;

If you modify the format of the input and output, will affect the subsequent format, you need to reset, generally in the format type before adding "No", you can;

Support, 8, 16, default 10, and uppercase (uppercase) mode;

Code:

* * * cppprimer.cpp * * Created on:2013.11.28 * author:caroline//*eclipse CDT, gcc 4.8.1*/  
      
#include <iostream> using namespace std; int main () {//control format, output std::cout << "default bool values:" << true << "" << FAL
            SE << "\nalpha bool values:" << std::boolalpha << true << "" << false  
    << Std::endl; Std::cout << "No reset bool:" << true << "" << false << Std::endl; No reset std::cout << std::noboolalpha << "reset bool:" << true << "" << false &LT;&L T Std::endl; base of reset//integer, display, uppercase//More highlights: http://www.bianceng.cnhttp://www.bianceng.cn/Programming/cplus/std::cout  
    << std::showbase; Std::cout << "Default: << <<" "<< 1024 << Std::endl; Default Std::cout << "Octal:" << Oct << << "" << 1024 << Std::endl;  
            8 std::cout << std::uppercase << "hex: << hex << <<" "<< 1024 << Std::nouppercase <<std::endl; 16 Std::cout << "decimal: << dec<< <<" "<< 1024 << Std::endl;  
    10 Std::cout << Std::noshowbase;  
return 0; }

Output:

default bool values:1 0  
Alpha bool values:true false  
No reset bool:true false  
reset bool:1 0  
Defau LT:20 1024  
octal:024 02000  
hex:0x14 0X400 decimal:20  
1024

Author: csdn Blog spike_king

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.