删除二进制文件中的记录? [英] Deleting a record within a binary file?

查看:51
本文介绍了删除二进制文件中的记录?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

过去整整一周我一直在处理二进制文件.我不知道该怎么做的一件事是有选择地从二进制文件中删除一条记录.这在c ++中可能吗?如果没有,您可以通过哪些方式进行此操作.

I've been messing around with binary files the last whole week. One thing I can't figure out how to do is selectively delete a record from the binary file. Is this possible in c++? If not, what are ways in which you can do this.

我正在考虑,也许创建一个没有内部记录的重复文件,但这对于非常大的数据文件而言似乎效率很低.有没有更有效的方法,或者有效率地复制文件的任何方法?我很惊讶可以删除文件,但不能有选择地从文件中删除.

I'm contemplating, maybe creating a duplicate file without the record inside, but that would seem rather inefficient for very large data files. Any more efficient ways, or any way of duplicating a file efficiently? I''m surprised there's ways to delete files, but not selectively delete from a file.

推荐答案

与内存中的数据结构不同,您不能从文件中提取记录.您必须:

Unlike data structures in memory, you can't pull out a record from a file. You have to:

  1. 将文件的内容读取到内存中的数据结构中
  2. 从内存中的数据结构中删除相关数据.
  3. 将更新后的数据结构写回到文件中.

这篇关于删除二进制文件中的记录?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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