Thursday, May 31, 2018

c++11 - How to check if a file exists in C++?

I want to determine if a file exists in C++ 11



I have the following codes:



ifstream inputFile(c);


if (!inputFile.good()) {
std::cout << "No file found" << '\n';
}


And



if (inputFile.peek() == std::ifstream::traits_type::eof()){
....

}



Which one is correct and idiomatic?

No comments:

Post a Comment

plot explanation - Why did Peaches&#39; mom hang on the tree? - Movies &amp; TV

In the middle of the movie Ice Age: Continental Drift Peaches' mom asked Peaches to go to sleep. Then, she hung on the tree. This parti...