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

c# - Validate object ID from GET to POST -

node.js - Custom Model Validator SailsJS -

php - Find a regex to take part of Email -