Kitty said:
I use " ifstream input_file("input.txt") " to open a file. I want to show a
warning message if "input.txt" does not exist. How can I do for that?
Standard C++ does not provide a way to determine the
existence of a file. You'll need a platform-specific
solution for that. Check your compiler and/or OS
documentation. The best you can do with standard C++
is determine whether an attempt to open a file succeeded
or failed. The actual reason for failure cannot be known
by standard means.
std::ifstream input_file("input.txt");
if(!input_file)
std::cerr << "Could not open input file\n";
else
/* etc. */
-Mike