第16周项目1:小玩文件(2)
2016-06-23 09:05
246 查看
/* *Copyright (c) 2016,烟台大学计算机学院 *All rights reserved. *文件名称 :第16周项目1:小玩文件(2) *作 者 : 于子娴 *完成日期 : 2016.6.23 *版 本 号 : v6.0 * *问题描述 : *输入描述 : *程序输出 : */ #include <iostream> #include <cstdlib> #include <fstream> using namespace std; int main() { fstream outfile,infile; infile.open("abc.txt",ios::in); // (1) if(!infile) { cout<<"Can’t open the file."<<endl; abort(); } outfile.open("newabc.txt",ios::out);//(2) if(!outfile) { cout<<"Can’t open the file."<<endl; abort(); } char buf[80]; int i=1; while(!infile.eof()) // (3) { infile.getline(buf, 80); // (4) outfile<<i++<<": "<<buf<<endl; //(5) } infile.close(); outfile.close(); return 0; }
相关文章推荐
- 第17周项目 1—小玩文件 (1)
- C++学习方法与心得
- 2012素数判定
- ftp爆破(python脚本)
- Thread Join方法
- java学习day9
- 敏捷开发的几条原则
- 用Java程序判断是否是闰年的简单实例
- 文件阅读(9)
- 第16周项目1:小玩文件(1)
- Oracle数据泵方式的数据库导入
- java学习day7
- java学习day8
- Scala中的apply实战详解
- 阅读笔记01
- 11-1-败者树-外部排序-第11章-《数据结构》课本源码-严蔚敏吴伟民版
- 简析.NET Core 以及与 .NET Framework的关系
- asp.net写入日志到文本文件
- 测试用例设计之边界值分析方法
- 文件阅读(8)