Click here to Skip to main content
15,906,558 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
can anyone please give me th sample code for deleting a text file that is created using fopen function so that for each execution a new file is created... Is it posible in VC++... Or please tell me how to clear the contents of the file so that for every execution the file is empty... please help me out...
Thank you...:confused:
Posted

Did you read the documentation for fopen in msdn[^]? It clearly says that when a file is open with mode = "w" then "... If the given file exists, its contents are destroyed." So I guess all you have to do is open the file again.

-Saurabh
 
Share this answer
 
You mean you want to have an empty file each time you open the file ? If yes, then just open the file in write mode. See the documentation[^] for more info.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900