您的位置:首页 > 其它

第十三周项目一2

2015-06-17 09:05 183 查看
(c)2015,烟台大学计算机与控制工程学院
*All rights reserved.
*文件名称:test.cpp
*作 者:李文贺
*完成日期:2015年6月17日
*版 本 号:v1.0
*问题描述:
*输入描述:
*程序输出:结果

#include <iostream>
#include <cstdlib>
#include <fstream>
using namespace std;

int main()
{
fstream  outfile,infile;
infile.open("abc.txt",ios::in);
if(!infile)
{
cout<<"abc.txt can't open. "<<endl;
abort();
}
outfile.open("newabc.txt",  ios::out);
if(!outfile)
{
cout<<"can't open the file."<<endl;
abort();
}
char buf[80];
int i=1;
while( !infile.eof()     )
{
infile. getline(buf,80) ;
outfile<< i++  <<":"<<buf<<endl;
}
infile.close();
outfile.close();
return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: