answersLogoWhite

0

That depends on the type of file and what you mean by "empty". Generally, fopen() called on an existing file, with the "w" option instead of the "a" option will truncate the file to zero length. To delete a file completely is a different process. Function truncate is your friend.

User Avatar

Wiki User

16y ago

Still curious? Ask our experts.

Chat with our AI personalities

ViviVivi
Your ride-or-die bestie who's seen you through every high and low.
Chat with Vivi
SteveSteve
Knowledge is a journey, you know? We'll get there.
Chat with Steve
JordanJordan
Looking for a career mentor? I've seen my fair share of shake-ups.
Chat with Jordan
More answers

opening the file in write mode will erase the contents.

fopen("myfile.txt","w");

User Avatar

Wiki User

15y ago
User Avatar

Add your answer:

Earn +20 pts
Q: How do you empty a file using C programming?
Write your answer...
Submit
Still have questions?
magnify glass
imp