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 <&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