64,637
社区成员
发帖
与我相关
我的任务
分享
#include <iostream>
#include <iomanip>
#include <fstream>
#include <string>
using namespace std;
int main()
{
ofstream out("test.txt");
out<<"00 11 22 33";
out.close();
string temp;
fstream io;
io.open("test.txt",ios::in|ios::out);
if(!io.good())
exit(1);
io.seekg(0,ios::beg);
io>>temp;
io.seekp(io.tellg());//设置输出指针为当前位置
io <<setw(3) <<2; //"2"覆盖了原来的"11"
io.close();
system("test.txt");
return 0;
}