从在C文件中删除一个字符 [英] Delete a character from a file in C

查看:181
本文介绍了从在C文件中删除一个字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我如何从一个文件中使用C程序删除几个字符?

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

我找不到任何predefined功能吧。

I could not find any predefined functions for it.

要了解的目的,我想通过套接字发送一个文件,如果N个字节发送成功,我想从文件中删除这些字节。最后,该文件将是空的。
任何其他方式能够有效地做到这一点?

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

推荐答案

如果他们是在年底,截断该文件在适当的长度。如果他们不那么你就需要重写文件。

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.

这篇关于从在C文件中删除一个字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆