124.C++输出小结

 1 #include <iostream>
 2 #include <iomanip>
 3 using namespace std;
 4 
 5 void main()
 6 {
 7     ////调用cout的成员函数输出到屏幕
 8     //cout.put('a').put('b').put('c');
 9     //char str[100] = "hello world";
10     ////        首地址    长度
11     //cout.write(str, strlen(str)).put('
');
12     //cout.write(str + 3, strlen(str + 3));
13 
14 
15     //设定长度
16     cout.width(40);
17     cout.fill('*');//fill 依赖于cout<<输出
18     cout << "hello" << endl;
19     
20 
21     float fl = 1.0;
22     cout.precision(20);
23     cout << fl << endl;
24 
25     cout.setf(ios::showpoint);//强制有小数点
26     cout << fl << endl;
27 
28     //设置16进制
29     cout.setf(ios::hex);
30     cout << 256 << endl;
31 
32     //十进制
33     cout << dec << 256 << endl;
34     //十六进制
35     cout << hex << 256 << endl;
36     //八进制
37     cout << oct << 256 << endl;
38 
39     cin.get();
40 
41 }
原文地址:https://www.cnblogs.com/xiaochi/p/8620068.html