如何在文件中间插入和删除一些字符? [英] How do I insert and delete some characters in the middle of a file?
本文介绍了如何在文件中间插入和删除一些字符?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想在文件中间插入和删除一些字符.
I want to insert and delete some chars in the middle of a file.
fopen() 和 fdopen() 只允许在最后追加.
fopen() and fdopen() just allow to append at the end.
是否有允许这些操作的简单方法或现有库?
Is there any simple method or existing library that allow these actions?
推荐答案
没有简单的方法.你已经手动完成了.例如:
There is no simple method. You have do it manually. For example:
- 将之前要插入的块读取到内存中
- 寻求新的职位
- 在新位置写入刚刚读取的块
- 返回到要插入的位置
- 写入新数据.
这篇关于如何在文件中间插入和删除一些字符?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文