I’m using fstream to open up .txt files with C++. So far it’s working great. However, I’d like my console to display an error message if the input_file can’t be opened. How should I go about this?
Snippet:
cin >> in_file_name ;
ifstream in_file(in_file_name.c_str());
in_file_str.assign(istreambuf_iterator<char>(in_file),
istreambuf_iterator<char>());
1 Answer