std::setw(size)与std::setfill(char)

头文件:
#include
#include
using namespace std;

 

功能: 

std::setw :需要填充多少个字符,默认填充的字符为' '空格

std::setfill:设置std::setw将填充什么样的字符,如:std::setfill('*')

 

示例:

 1 #include 
 2 #include 
 3 #include 
 4 #include 
 5 
 6 int _tmain(int argc, _TCHAR* argv[])
 7 {
 8      int a = 1;
 9      //输出:    1
10      std::cout<4)<std::endl;
11      //输出: ***1
12      std::cout<4)<'*')<std::endl;
13 
14      //输出:***12
15      int b = 2;
16      std::cout<4)<'*')<std::endl;
17      system("pause");
18      return 0;
19 }

 

你可能感兴趣的:(std::setw(size)与std::setfill(char))