std::setw(size)与std::setfill(char)
头文件:
#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)的更多相关文章
- 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版本的代码,但 ...
- 你想知道的 std::vector::push_back 和 std::vector::emplace_back
引言 C++ 11 后,标准库容器 std::vector 包含了成员函数 emplace 和 emplace_back.emplace 在容器指定位置插入元素,emplace_back 在容器末尾添 ...
- 'bool std::operator <(const std::_Tree<_Traits> &,const std::_Tree<_Traits> &)'
error C2784: 'bool std::operator <(const std::_Tree<_Traits> &,const std::_Tree<_Tra ...
- 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 ...
- std::array中的std::get<n>()
模板函数std::get<n>()是一个辅助函数,它能够获取到容器的第 n 个元素.模板参数的实参必须是一个在编译时可以确定的常量表达式,编译时会对它检查. get<n>()模 ...
- 使用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 ...
- 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 ...
- 将std::array转换成std::tuple
template<typename Array, std::size_t... Index> decltype(auto) array2tuple_impl(const Array& ...
- 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 ...
随机推荐
- 防火墙之iptables
Netfilter/Iptables(以下简称Iptables)是unix/linux自带的一款优秀且开放源代码的完全自由的基于包过滤的防火墙工具,它的功能十分强大,使用非常灵活,可以对流入和流出服务 ...
- 使用URLOS在linux系统中极速部署NFS共享存储服务
如何在linux系统里搭建NFS服务?其实我们只需要安装一个URLOS面板,然后就能在3分钟内将NFS服务部署完成.近日,URLOS在应用市场中上架了一款NFS应用,它可以让我们的节点主机在3分钟内极 ...
- bert系列一:《Attention is all you need》论文解读
论文创新点: 多头注意力 transformer模型 Transformer模型 上图为模型结构,左边为encoder,右边为decoder,各有N=6个相同的堆叠. encoder 先对inputs ...
- 【Python开发】Python中的class继承
继承是面向对象的重要特征之一,继承是两个类或者多个类之间的父子关系,子进程继承了父进程的所有公有实例变量和方法.继承实现了代码的重用.重用已经存在的数据和行为,减少代码的重新编写,python在类名后 ...
- jenkins pipline 和 jenkinsfile
Jenkins Pipeline(或简称为 "Pipeline")是一套插件,将持续交付的实现和实施集成到 Jenkins 中.Jenkins Pipeline 提供了一套可扩展的 ...
- [python] a little deep learning case
from numpy import exp, array, random, dot class NeuralNetwork(): def __init__(self): random.seed(1) ...
- mybatis 基础(二) 动态sql 关于where if / where choose when otherwise
个人理解: where if就相当于正常的java中的if 语句,如果有多个条件组合判断的话用 and, or连接 而where choose when otherwise choose就好像是swi ...
- 错误:编码GBK的不可映射字符解决办法
今天在cmd测试java代码的时候遇到了一个错误 解决办法: 输入javac -encoding utf-8 文件名.java 原因: 由于JDK是国际版的,我们在用javac编译时,编译程序首 ...
- 房地产大佬潘石屹推荐学Python编程,这本从0到1就够了
潘石屹推荐学Python编程,很多人都不相信,他的微博真真切切. 连房地产都开始学Python了,因为要听懂机器,让机器为我所用. 再不学习Python真的晚了!!!! 如何学? 怎么学? 还是推荐高 ...
- 使用Python基于OpenCV和Tesseract的OCR
OCR OCR(Optical Character Recognition,光学字符识别)是指电子设备(例如扫描仪或数码相机)检查纸上打印的字符,通过检测暗.亮的模式确定其形状,然后用字符识别方法将形 ...