Delete a character from a file in 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?


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.