在线文档教程
C++
输入/输出 | Input/output

std::resetiosflags

STD::树脂旗

Defined in header
/*unspecified*/ resetiosflags( std::ios_base::fmtflags mask

在表达式中使用时out << resetiosflags(mask)或in >> resetiosflags(mask),清除流的所有格式标志。out或in由mask...

参数

mask-bitmask of the flags to clear

返回值

返回未指定类型的对象,以便在str类型的输出流的名称。std::basic_ostream<CharT, Traits>或std::basic_istream<CharT, Traits>,然后表达str << resetiosflags(mask)或str >> resetiosflags(mask)行为就像执行了以下代码:

str.setf(std::ios_base::fmtflags(0), mask

二次

#include <sstream> #include <iostream> #include <iomanip> int main() { std::istringstream in("10 010 10 010 10 010" int n1, n2; in >> std::oct >> n1 >> n2; std::cout << "Parsing \"10 010\" with std::oct gives: " << n1 << ' ' << n2 << '\n'; in >> std::dec >> n1 >> n2; std::cout << "Parsing \"10 010\" with std::dec gives: " << n1 << ' ' << n2 << '\n'; in >> std::resetiosflags(std::ios_base::basefield) >> n1 >> n2; std::cout << "Parsing \"10 010\" with autodetect gives: " << n1 << ' ' << n2 << '\n'; }

二次

产出:

二次

Parsing "10 010" with std::oct gives: 8 8 Parsing "10 010" with std::dec gives: 10 10 Parsing "10 010" with autodetect gives: 10 8

二次

另见

setfsets specific format flag (public member function of std::ios_base)
setiosflagssets the specified ios_base flags (function)

© cppreference.com

在CreativeCommonsAttribution下授权-ShareAlike未移植许可v3.0。

http://en.cppreference.com/w/cpp/io/manip/resarchos旗帜