如果if流不再使用,则使用ios::clear()。

问题描述 投票:-1回答:1

我想知道是否用 ios::clear() 或不在这段代码中使用。

ifstream is;
is.open (file_name, ios::binary); 
if (is.fail()) 
    is.clear(), std::cout<<"error\n", std::exit(9);

如果我在代码中不再使用ifstream(因为... std::exit()),我必须要 ios::clear() 的流?

c++ iostream
1个回答
0
投票

调用 clear() 只清除由 fail(), bad()eof().

它不会以任何其他方式影响流。

© www.soinside.com 2019 - 2024. All rights reserved.