// page221.cpp : 定义控制台应用程序的入口点。
//C++面向对象程序设计
//从文件infile.datzhong读取3个数,求和,将文件写入文件outfile.dat
#include "stdafx.h"
#include <iostream>
#include <fstream>
#include <cstdlib>
int _tmain(int argc, _TCHAR* argv[])
{
using namespace std ;
int a;
ifstream in_stream ;
ofstream out_stream;
in_stream.open("infile.dat");
if(in_stream.fail())
{
cout << " Input file opening failes.\n";
exit(1);
}
out_stream.open("outfile.dat");
if (out_stream.fail())
{
cout << " Output file opening failed.dat.\n";
exit(1);
}
int frist , second ,third ;
in_stream >> frist >> second >> third ;
out_stream << " The sum of the frist 3\n"
<< " number in infile.dat\n"
<< " is " << (frist + second + third)
<< endl ;
in_stream.close();
out_stream.close();
cin >> a;
return 0;
}
ps:用的是chinanet哦===没网确实不方便啊
4400

被折叠的 条评论
为什么被折叠?



