C++相談室 part166 (347レス)
C++相談室 part166 http://mevius.5ch.net/test/read.cgi/tech/1745631298/
上
下
前次
1-
新
通常表示
512バイト分割
レス栞
抽出解除
必死チェッカー(本家)
(べ)
自ID
レス栞
あぼーん
322: デフォルトの名無しさん (ワッチョイ 8101-1tcn) [sage] 2025/06/17(火) 11:27:27.12 ID:2aAnRxo/0 >>321 ifs.close()前にifs.fail()は真を返す #include <iostream> #include <fstream> int main() { constexpr auto path = "tmp.txt";//なんでもいいです std::ifstream ifs(path); if(ifs.fail()){ std::cerr << "File open error: " << path << std::endl; return -1; } std::string buf; std::cout << "0: " << ifs.fail() << '\n'; while(std::getline(ifs, buf)) std::cout << buf << std::endl; std::cout << "1: " << ifs.fail() << '\n'; ifs.close(); //←これ std::cout << "2: " << ifs.fail() << '\n'; if(ifs.fail()){ std::cerr << "File close error: " << path << std::endl; return -1; } return 0; } http://mevius.5ch.net/test/read.cgi/tech/1745631298/322
メモ帳
(0/65535文字)
上
下
前次
1-
新
書
関
写
板
覧
索
設
栞
歴
スレ情報
赤レス抽出
画像レス抽出
歴の未読スレ
AAサムネイル
Google検索
Wikipedia
ぬこの手
ぬこTOP
0.992s*