I have this code :
static std :: ifstream s_inF(argv[j]);
std :: cin.rdbuf(s_inF.rdbuf());
How can I make sure it opened the file properly and there is no problem ?
I mean I would like to write something like:
static std :: ifstream s_inF(argv[j]);
std :: cin.rdbuf(s_inF.rdbuf());
if(.....)
{
cout << "can not open the file" << endl;
return 0;
}
...
.....
....
cin.close();
any suggestion ?
You can use is_open
for this. See here:
http://www.cplusplus.com/reference/fstream/ifstream/is_open/