Checking if a file opened successfully with ifstream

后端 未结 4 1247
我在风中等你
我在风中等你 2020-12-10 01:28

I have the following that will open a file for reading. However, I want to check to make sure that the file was open successfully, so I am using the fail to see if the flags

4条回答
  •  时光取名叫无心
    2020-12-10 02:15

    Your error is because you are using ios::fail() as a static method when it is actually a member method.

    if (input_stream.fail())
    {
        ...
    }
    

提交回复
热议问题