CIN and cout input and output formats
Input
1;. Cin
Enter end condition: Encounter Enter, Space, Tab key.
int A;
>> A;
Signed input, such as input (A,B,C)
int>>1','>> b;
2> . Cin.get(array name, length, Terminator)
Where the Terminator is an optional parameter, the number of characters read into is (length-1), The Terminator specifies the end string read characters, the default is Enter,ch=cin.get () and Cin.get (CH) equivalent.
// cin.get (C1, 8 , " q ); // "asdf" encountered ' Q ' end, read up to 7 characters!!! cin. get (C2); // get the character "Q" cin.clear () cout << C1 << Span style= "color: #800000;" > " << C2 << Endl; // "a S" prints two characters cout << (int ) C2 < < Endl; // 113
3 . Cin. getline()
Cin.getline () When the input is very long, it will cause the CIN function error, the subsequent CIN operation will no longer execute.
// enter "12345" 5); // "1234" reads 4 characters of cin >> ch; // "0" << (int) ch << endl;
Here in fact the CIN>>CH statement is not executed, because CIN error!
Output
1 bool type output
cout <<true<<"or"<<false<<endl;//1 or 0cout << Boolalpha <<true<<"or"<<false<<endl;//true or False
cout << noboolalpha << true <<" or " << false <<Endl; // 1 or 0 cout << Boolalpha <<0<<endl;//0 Reason: 0 is not equivalent to false in cout
2 integral type output
Const int ; // ' ival ' is constant, so value neverchange cout <<oct << ival <<endl; // 8 binary cout <<dec << ival <<endl; // 017 10 binary cout <// 0x11 17.01 <<endl; // 17.01: Not affected
cout<<Showbase<<Uppercase;// Show base when printing integral values
cout<< Hex<<15<<Endl; // 0XF uppercase Form
cout << nouppercase;
cout << hex << <<Endl; // 0xf lowercase form
cout<< noshowbase; // Reset State of the stream
3 floating-point output
cout<<Setprecision (4)<<12.345678 <<Endl;//12.35 outputs a total of four bits rounded (rounded)
cout << Span style= "color: #000000;" >setprecision (1012.345678 << ENDL; // 12.345678 In fact there is a rounded inside, and the result is just the same as the original value
cout << Cout.precision () << //
cout << Setiosflags (iOS:://12 output Two-bit
C--, CIN and cout input and output formats