setfill的使用

// 详细解析

// setfill的使用
#include<iostream>
#include<iomanip>
using namespace std;

int main()
{

    double num = 123.456 ;
    cout << setw( 9 ) << setfill( '*' ) << num << endl;
    cout << setw( 9 ) << setfill( '0' ) << num << endl;
    cout << setw( 10 ) << num << endl;

    return 0;
}


输出结果:
**123.456
00123.456
000123.456

详解:流操作符setfill用于把占位符从空格改变为其他字符
,setw则是设置数据的宽度


 

你可能感兴趣的:(C++,setfill,流操作符)