c++ - Detecting if a file is open -
how can detect if file open in c++? trying use code this:
int main() { ifstream file("file.txt"); if ( /*here comes check if file open*/ ) cout<<"file open successfully"; else cout<<"file couldn't opened. check if file not used program or if exists"; }
you looking function is_open()
if(file.is_open()){}
Comments
Post a Comment