1.流含义
2.流类
3.流对象
4.流对象的函数
举例:
要求:数据结构中经常需要对齐输出数据,应该怎么做?
1.头文件
#include<iomanip>
2.创建表格头
cout << setiosflags(ios::left) << setw(8) << "姓名"<< setw(8) << "性别"<< setw(8) << "年龄" << endl;
3.输入数据
char name[5][10] = {"王建","张辉","李素","如帅","外库"}; char sex[5][3] = { "男","男","男","女","女" }; int age[5] = { 10,12,15,10,19 }; for (int i = 0;i < 5;i++) {cout << setiosflags(ios::left) << setw(8) << name[i]<< setw(8) << sex[i]<< setw(8) << age[i] << endl; }
结果: