bool is return type of isopen() function - File Handling

Q.  __________ is return type of is_open() function.
- Published on 17 Jul 15

a. int
b. bool
c. float
d. char *

ANSWER: bool
 

    Discussion

  • Nihal   -Posted on 06 Oct 15
    bool is return type of is_open() function. It returns true if file successfully open otherwise it returns false.
    Example:
    int main () {

    ifstream fileObj;
    fileObj.open ("test1.txt");
    if (fileObj.is_open())
    {

    cout<<"No problem to open file";
    }
    else
    {
    cout << "Error opening file";
    }
    return 0;
    }

Post your comment / Share knowledge


Enter the code shown above:

(Note: If you cannot read the numbers in the above image, reload the page to generate a new one.)