//Ex6_26.cpp
#include "iostream" 
#include "fstream" 
using namespace std;
void main() 
{int i,a;
 ofstream out("c:\\mydata.dat",ios::out|ios::binary);   //按二进制方式打开输出文件
 if(!out) 
	{cout<<"can't open c:\\mydata.dat!"<<endl; 
	 abort();} 
 for(i=1;i<20;i=i+2)
	 out.write((char *)&i,sizeof(int));  //将整型指针转换成字符型指针以符合write
 out.close();
 ifstream in("c:\\mydata.dat",ios::in|ios::binary); 
 if(!in) 
	{cout<<"can't open c:\\mydata.dat!!"<<endl; 
	 abort();} 
 for(i=1;in.read((char *)&a,sizeof(int));i++)
	{cout<<a<<'\t';
     if(i%5==0) cout<<endl;
	}
 in.close();
}
