#include <iostream.h>
#include <fstream.h>
int main()
{
fstream fs;//创建流对象
fs.open("d://test",ios::in|ios::out);//以读写方式打开文件
if(fs.fail())
{
cout<<"open file error!";
}
else
{
fs.seekp(4,ios::beg);//设置写指针//ios::beg从文件头开始,把文件指针移动有OFF指定的距离
fs.put('X');
char contents[100];
fs.seekg(0,ios::beg);//设置读指针//IOS::CUR,从当前开始,````````````````````````
fs.get(contents,100);
cout<<contents;
}
fs.close();
return 0;
}