fstream outfile,infile;
outfile.open(\ if(!outfile) {
cout<<\ abort(); }
outfile<<\ outfile<<\ outfile<<\ outfile.close();
infile.open(\ if(!infile) {
cout<<\ abort(); }
char line[80]; int i=0;
while(!infile.eof())
{
i++;
infile.getline(line,sizeof(line)); cout<
}
infile.close();
6. 程序如下
//ch9_ex3_6.cpp #include
fstream f(\ for(int i=0;i<20;i++)
f.write((char *)&i,sizeof(int)); streampos pos=f.tellp(); for(i=20;i<40;i++)
f. write((char *)&i,sizeof(int));
f.seekg(pos);
f. read((char *)&i,sizeof(int)); cout<<\ f. seekp(0,ios::beg); for(i= 100;i< 140;i++)
f. write((char *)&i,sizeof(int)); f.seekg(pos);
f.read((char *)&i,sizeof(int)); cout<<\}
7. 程序如下
//ch9_ex3_7.cpp #include
char ch; fstream file;
file.open(\ if(!file) {
cout<<\ abort(); }
file<<\ file.seekg(0,ios::beg); while(!file.eof()) {
streampos here=file.tellg(); file.get(ch); if(ch==' ')
cout< cout< 四、编程题 1. 编写一个程序,显示九九乘法表。 2. 编程实现任意类型文件的拷贝。 3. 编写一个程序,统计文件abc.txt的字符个数。