添加字符串到文件中的问题,谢谢
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
using namespace std;
int main(){
string fname;
ifstream in( "abc.txt ",ios::out|ios::in);
ostream out(in.rdbuf());
out < < "hello : ";
out.seekp(0,ios::beg);
out < < "I am fine! ";
in.seekg(0,ios::beg);
system( "pause ");
}
想把I am fine!字符串插入到文件头,但发现是覆盖,找了半天书,也没有发现方法,帮帮忙吧,谢谢~~~~~~~~~~
[解决办法]
只能先读出来。
写I am fine!
然后把剩下的写进去
[解决办法]
只好手动喽
[解决办法]
支持手动