If fopen( path, “w” ) succeeds, then the file will be truncated. If the fopen fails, are there an guarantees that the file is not modified?
Share
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.
No there are no guarantees about the state of a file if
fopen(path, "w")fails. The failure could be coming from any operation from opening the file, committing the truncation to disk, etc … The only guarantee a failure provides is that you don’t have access to the file.