头文件:
#include <iostream>
#include <iomanip>
using namespace std;

功能: 

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

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

示例:

 #include <stdio.h>
#include <tchar.h>
#include <iostream>
#include <iomanip> int _tmain(int argc, _TCHAR* argv[])
{
int a = ;
//输出: 1
std::cout<<std::setw()<<a<<std::endl;
//输出: ***1
std::cout<<std::setw()<<std::setfill('*')<<a<<std::endl; //输出:***12
int b = ;
std::cout<<std::setw()<<std::setfill('*')<<a<<b<<std::endl;
system("pause");
return ;
}

std::setw(size)与std::setfill(char)的更多相关文章

  1. VC++ : error LNK2001: unresolved external symbol "__declspec(dllimport) public: __thiscall std::basic_string<wchar_t,struct std::char_traits<wchar_t>

    最近学习Google Breakpad,将其用在了自己的项目中,编译的版本为VS2010,没有什么问题.但是为了和之前的程序兼容,需要使用VS2008版本的程序,于是又编译了VS2008版本的代码,但 ...

  2. 你想知道的 std::vector::push_back 和 std::vector::emplace_back

    引言 C++ 11 后,标准库容器 std::vector 包含了成员函数 emplace 和 emplace_back.emplace 在容器指定位置插入元素,emplace_back 在容器末尾添 ...

  3. 'bool std::operator <(const std::_Tree<_Traits> &,const std::_Tree<_Traits> &)'

    error C2784: 'bool std::operator <(const std::_Tree<_Traits> &,const std::_Tree<_Tra ...

  4. error: #error This file requires compiler and library support for the ISO C++ 2011 standard. This support is currently experimental, and must be enabled with the -std=c++11 or -std=gnu++11 compiler op

    caffe c++11编译问题 问题:error: #error This file requires compiler and library support for the ISO C++ 201 ...

  5. std::array中的std::get<n>()

    模板函数std::get<n>()是一个辅助函数,它能够获取到容器的第 n 个元素.模板参数的实参必须是一个在编译时可以确定的常量表达式,编译时会对它检查. get<n>()模 ...

  6. 使用log4cplus时遇到的链接错误:无法解析的外部符号 "public: static class log4cplus::Logger __cdecl log4cplus::Logger::getInstance(class std::basic_string<wchar_t,struct std::char_traits<wchar_t>,

    #include "stdafx.h" #include <log4cplus/logger.h> #include <log4cplus/loggingmacr ...

  7. Error 2 error C2784: 'bool std::operator <(const std::_Tree<_Traits> &,const std::_Tree<_Traits> &)'

    Error 2 error C2784: 'bool std::operator <(const std::_Tree<_Traits> &,const std::_Tree ...

  8. 将std::array转换成std::tuple

    template<typename Array, std::size_t... Index> decltype(auto) array2tuple_impl(const Array& ...

  9. mod_tile编译出错 -std=c++11 or -std=gnu++11

    make[1]: 正在进入文件夹 /home/wml/src/mod_tile-master' depbase=echo src/gen_tile.o | sed 's|[^/]*$|.deps/&a ...

随机推荐

  1. Cisco路由器的dhcp服务的配置的命令

    Router(config)#IP DHCP POOL Jason Router(dhcp-config)#net 172.16.10.0 255.255.255.0 Router(dhcp-conf ...

  2. selenium—alert用法

    切换到弹框: switch_to_alert() ① alert.accept()  确认弹框 driver.switch_to_alert().accept() ② alert.dismiss() ...

  3. python 爬虫 requests模块(response常用属性)

    response常用属性 content获取的response对象中的二进制(byte)类型的页面数据response.content 返回响应状态码response.status_code 200 ...

  4. p1000 A+B问题

    题目描述 Description 输入两个整数A和B,输出他们的和 输入描述 Input Description 输入为一行,包含两个整数A,B.数据保证A与B都在2^31-1的范围内 输出描述 Ou ...

  5. 【经典问题】maximum subset sum of vectors

    AtCoder Beginner Contest 139 Task F Engines 题目大意 给定 $n$ 个二维向量,从中选出若干个,使得它们的和的模最大. 分析 这是一个经典问题,还有一种提法 ...

  6. PHP 补零操作

    str_pad(string,length,pad_string,pad_type)//参数 描述string //必需.规定要填充的字符串.length //必需.规定新的字符串长度.如果该值小于字 ...

  7. springboot读取配置不存在报错

    @Value("${log.regId}")private String regId = "123123"; String regId = env.getPro ...

  8. eclipse运行jsp出现404错误怎么办?

    Window/Show View/Other/Server/Servers/双击“Tomcat v7.0 Server at localhost”在Server Locations配置中选择第二个选项 ...

  9. java中代码块和构造方法以及普通方法的代码执行顺序总结

    说实话,这块真的不好理解啊~都怪jvm  执行顺序搞这么复杂,哼╭(╯^╰)╮ 但是  我们能怎么办,只能研究呗!!! !:首先,毫无置疑的,静态代码块在加载时就执行了,所以肯定是最先执行的.... ...

  10. 分布式的几件小事(九)zookeeper都有哪些使用场景

    1.zookeeper介绍 ZooKeeper是一个分布式的,开放源码的分布式应用程序协调服务,是Google的Chubby一个开源的实现,是Hadoop和Hbase的重要组件.它是一个为分布式应用提 ...