answersLogoWhite

0


Best Answer

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

15y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

15y ago

opening the file in write mode will erase the contents.

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

This answer is:
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
Related questions

What is step involve is using data file in c plus plus programming?

Declaration of file pointer opening of file in desired mode. performing the desired operation. closing the file


How do you stop writing a file in c by using ctrl z in cpp?

Ctrl+Z mean EOF in WinDos, no matter what programming language you are using.


How do you detect an empty file in a c program?

Seek to the end of the file (fseek) and check how many bytes are in the file If the byte count is zero the file is empty.


Is MySQL a programming language?

MySQL was written and developed using the C and C++ programming languages.


How do you do C programming on your Windows?

C programming can be started on Windows by using a suitable IDE (these include compilers) such as Dev-C++


What is bak in C programming?

Nothing, but as a file-extension it means backup.


What is a scatter file in c or c double plus programming?

helps you to organise the memory as you want


What are the applications using C programming?

One application that uses c programming is Microsoft Visual Studio 2008.


Examples on structures of C programming?

'struct tm' (time.h) and 'FILE' (stdio.h)


Wap to copy one file to another in C programming?

#include<stdio>


What is a scatter file in c or c plus plus programming?

Scatter File is a linker script file used by RVCT/Keil for ARM processors. It is used by arm linker.


What are the four file commands required to read and write to a file in C programming?

fopen, fread, fwrite, fclose