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

Popular posts from this blog

javascript - Google App Script ContentService downloadAsFile not working -

javascript - Function overwritting -

c# - Exception when attempting to modify Dictionary -