C++相談室 part166 (607レス)
上
下
前
次
1-
新
322
(1)
:
(ワッチョイ 8101-1tcn)
06/17(火)11:27
ID:2aAnRxo/0(1)
AA×
>>321
[240|
320
|
480
|
600
|
100%
|
JPG
|
べ
|
レス栞
|
レス消
]
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
前には真を返す なんでもいいです これ
上
下
前
次
1-
新
書
関
写
板
覧
索
設
栞
歴
あと 285 レスあります
スレ情報
赤レス抽出
画像レス抽出
歴の未読スレ
AAサムネイル
ぬこの手
ぬこTOP
0.030s