在文件C ++中编写 [英] Writing in file C++

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

问题描述

如何写入文件的特定位置?我的文件包含以下信息:

How can I write into a specific location of a file? My file contains the following info:

100 msc

我要更新为:

100 10 20 34 32 43 44

所以我想跳过 100 msc 与新的输入数组。

So I want to skip 100 and overwrite msc with the new input array.

推荐答案

知道是读入文件的完整内容,然后使用一些字符串操作来覆盖你需要的。然后,您可以将修改的信息写回同一个文件,覆盖其内容。

The best way that I know of is to read in the complete contents of the file, and then use some string manipulations to overwrite what you need. Then you can write back the modified information to the same file, overwriting its contents.

这篇关于在文件C ++中编写的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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