consider the below code snippet.
{
....
FILE *fptr = fopen("file_that_does_not_exist","r");
...
}
here, if fopen fails, do we still need to call fclose() for some cleanup ??
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Its simple friend, i mean just imagine…. Do you have to shutdown a computer even if it fails to boot up…. 😀
Some extra tip : fclose is used just for the sake of freeing the file so that it could be used by some other application or module, as it is not a sharable resource.
Also, fclose means you now free the pointer you were using and can use it for any other file.