用stringstream进行格式化输出
来源:互联网 发布:2016年淘宝双11销售额 编辑:程序博客网 时间:2024/06/06 11:36
用C++的方式也可以进行格式化输出,
下面一段代码使用stringstream进行格式化输出,供参考。
#include <sstream>
#include <iostream>
int main()
{
std::stringstream ss_time;
int year = 2012;
int month = 1;
int day = 30;
int hour = 20;
int minute = 30;
int second = 0;
ss_time << "time is ";
ss_time.fill('0');
ss_time.width(4);
ss_time << year << "-";
ss_time.width(2);
ss_time << month << "-";
ss_time.width(2);
ss_time << day << " ";
ss_time.width(2);
ss_time << hour << ":";
ss_time.width(2);
ss_time << minute << ":";
ss_time.width(2);
ss_time << second << "\n";
std::cout << ss_time.str();
system("pause");
return 0;
}
- 用stringstream进行格式化输出
- 用stringstream进行格式化输出
- 用stringstream进行格式转换
- Python进行JSON格式化输出
- 用Java对JSON字符串进行格式化输出
- 用Java对JSON字符串进行格式化输出
- 关于stringstream的格式化
- DataGrid输出Excel并进行格式化处理
- 处理Date对象时进行格式化输出
- 对STL的string进行格式化输出
- 产生随即字符,并进行格式化输出
- 使用cout来进行格式化输出
- 使用cout进行格式化输出(1)
- 使用cout进行格式化输出(2)
- 用printf 格式化输出
- 用cout进行格式化
- matlab:用sprintf()格式化输出
- DataGrid输出到Excel并进行格式化处理
- android扫盲
- 位段
- C# DataRowState - 状态更改细节
- backtrack5 r1 install arachni
- 程序员技术练级攻略
- 用stringstream进行格式化输出
- 【並查集】淩辱
- 关于Java中的递归操作--(以将一个正整型十进制数转换为二进制数为例)
- VS2010安装报错,提示“ 无法打开数据文件deffactory.dat”
- 动态规划——矩阵连乘问题
- Boost Productivity Greatly With CodeSmith's Help During ASP.NET Development
- struts2下载文件示例
- 使用CFileDialog后相对路径的图片加载失败的问题
- Linux Command and Tools(updating)