Question : is_open() not in ifstream ?

I am compiling on multiple Unix platforms.

The statements:

  ifstream file("o", ios::binary | ios::ate);
       
  if(file.is_open()) { ...

generate a compiler error: "is_open is not a member of "class ifstream".

How can I fix this for the AIX platform ?

Answer : is_open() not in ifstream ?

>>>> if(file.is_open()) {
In case I am wrong and you were using std::basic_ifstream but nevertheless don't have  is_open member function you simply could do



  std::ifstream file("o", ios::binary | ios::ate);
       
  if(file) { ...

In case of an open error the ifstream sets the fail-bit what could be checked by

   if (file)

Note, if using old ifstream the latter won't work. You then have to check for the fail-bit, e. g. by

  if (!file.good())    


Random Solutions  
 
programming4us programming4us