头文件:
#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. Rate Limiter

    Whenever you expose a web service / api endpoint, you need to implement a rate limiter to prevent ab ...

  2. <<大道至简>>伪代码

    import.java.大道至简.* public class YuGong { public static void main(String [] args) throws IOException ...

  3. 小记--------spark内核架构原理分析

      首先会将jar包上传到机器(服务器上)     1.在这台机器上会产生一个Application(也就是自己的spark程序)     2.然后通过spark-submit(shell) 提交程序 ...

  4. Fidder抓包设置

    1, 谷歌浏览器中:

  5. 协程+IO切换+小爬虫

    from gevent import monkeymonkey.patch_all() import geventimport requests def f1(url): print(f'GET:{u ...

  6. Android新版xUtils3工具类相关debug

    首先出现问题是 build.gradle中的csayısıom.lidroid.xutils:xutils:2.6.13报错了,所以想到是版本的问题,github上搜了xutils发现有新版xutil ...

  7. cut--修剪小能手

    cut命令 cut原理:以每一行位一个处理对象. 参数选项 解释说明 -b 以字节为单位进行分割 -c 以字符为单位进行分割(对切割中文有奇效) -d 自定义分隔符号,默认以tab为分隔符 1:-b ...

  8. MySql查询进阶

    1.1 as关键字 用于 给显示结果中字段 或者 表 起别名 select 别名.字段名 from 表名 as 别名 where 条件语句 # 对字段起别名 select id as '编号', na ...

  9. mongodb的简单操作记录

    由于项目上需要对mongodb进行监控,所以需要先熟悉下什么是mongobd以及mongodb的简单操作 mongodb的安装: curl -O https://fastdl.mongodb.org/ ...

  10. 安装Anaconda3-201812详解

    Anaconda指的是一个开源的Python发行版本,其包含了conda.Python等180多个科学包及其依赖项.  因为包含了大量的科学包,Anaconda 的下载文件比较大(约 531 MB), ...