0
如何检测文件是否以C++打开? 我试图用这样的代码:检测文件是否打开
int main()
{
ifstream file("file.txt");
if (/*here comes the check if file is open*/) cout<<"File open successfully"; else cout<<"File couldn't be opened. Check if the file is not used by another program or if it exists";
}
你尝试'file.is_open()'? – 101010
你的意思是'if(file.is_open)...'吗? – Laurcons
不,我的意思是'file.is_open()',[std :: istream :: is_open()](http://www.cplusplus.com/reference/fstream/ifstream/is_open/) – 101010