c++

Delete a character from a file in C

c++

How can I delete few characters from a file using C program?

I could not find any predefined functions for it.

To understand the purpose, I am trying to send a file through a socket, if N bytes are sent successfully, I want to delete those bytes from the file. At the end, the file will be empty.
Any other way to do this efficiently?

Thanks
Pradeep

Best Solution

If they're at the end, truncate the file at the appropriate length. If they're not then you'll need to rewrite the file.