Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/136.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 如何显示和填充到ostream中?_C++ - Fatal编程技术网

C++ 如何显示和填充到ostream中?

C++ 如何显示和填充到ostream中?,c++,C++,我正在尝试将时间(m_min)写入HH:MM格式的流中,[如果数字是个位数,则将空格加上零] 我的时间模块仅以分钟为单位保存时间,但将以HH:MM的格式显示和读取时间 如何正确地将此格式填充到流中显示 例如:03:02、16:55、234:06) 或者,您可以简单地将分钟数拆分为小时+分钟,然后根据需要使用and来填充。具体来说,您可以使用,std::right和std::setw。 std::ostream& write(std::ostream& ostr) const;

我正在尝试将时间(m_min)写入HH:MM格式的流中,[如果数字是个位数,则将空格加上零]

我的时间模块仅以分钟为单位保存时间,但将以HH:MM的格式显示和读取时间

如何正确地将此格式填充到流中显示

例如:03:02、16:55、234:06)

或者,您可以简单地将分钟数拆分为小时+分钟,然后根据需要使用and来填充。具体来说,您可以使用,
std::right
std::setw
std::ostream& write(std::ostream& ostr) const;