/*
*Copyright(c) 2016.烟台大学计算机与控制工程学院
*ALL rights reserved.
*文件名称:test.cpp
*作者:杨驰
*完成日期:2016年6月14
*问题描述:读并运行下面的两个程序,分别用记事本和二进制文件阅读器(请自行下载Binary Viewer)。查看其内容,并理解二进制文件存储的原理
*/
#include <iostream>
#include <fstream>
#include <cstdlib>
using namespace std;
int main( )
{
int a;
ofstream outfile("f1.dat",ios::out);
if(!outfile)
{
cerr<<"open error!"<<endl;
exit(1);
}
cin>>a;
outfile<<a<<endl;
outfile.close();
return 0;
}
运行结果: