0
我有這樣的代碼:如何確保cin正確打開文件?
static std :: ifstream s_inF(argv[j]);
std :: cin.rdbuf(s_inF.rdbuf());
我怎樣才能確保它正常打開的文件,有沒有問題?
我的意思是,我想寫出類似:
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();
什麼建議嗎?
謝謝配合! –