#include 学习<第一记> setfill, setw

就看了之前记录的一个代码段 发现什么都不懂了 又去查
含义较多 我一点点的来记吧

#include
#include
using namespace std;

int _tmain(int argc, _TCHAR* argv[])
{
    cout << setfill('*') << setw(2) << 21 << endl;
    cout << setw(3) << 21 << endl;
    cout << setw(4) << 21 << endl;
    cout << setfill(' ');
    return 0;
}

//输出
21
*21
**21

setfill会一直影响到下一次调用setfill函数,所以后续都是*
setw是设置需要输出的宽度 剩余就按setfill里面的内容去填充
比如setw(4) 输出4个字符 后面2个字符是21 前面填充2个*

小记到此

你可能感兴趣的:(#include 学习<第一记> setfill, setw)