第14周 项目一-小玩文件(1)
2015-06-10 09:02
274 查看
(1)下面程序的功能是统计文本文件abc.txt中的字符个数,请填空将程序补充完整。
答案:
<fstream>
ios::in
!file.eof()
++i
close()
#include <iostream> #include <cstdlib> #include _____________ // (1) using namespace std; int main() { fstream file; file.open("abc.txt", _________); // (2) if(!file) { cout<<"abc.txt can’t open."<<endl; exit(1); } char ch; int i=0; while( _____________) // (3) { file.get(ch); _____________; // (4) } cout<<"Character: "<<i<<endl; file._____________;// (5) return 0; }
答案:
<fstream>
ios::in
!file.eof()
++i
close()
相关文章推荐
- Android中Spanner获取选中内容和选中位置,根据位置选择对象
- Spring 简介
- 如何做一个软件项目经理? ----写给公司所有的开发人员
- angular中ng-options的用法
- tornado初步 ppt分享
- 第14周程序阅读 例6.3
- OpenWrt系统安全改进<四> --- Web UI权限分级
- (转)位计算的诸多算法(计算二进制1的个数)
- 第十四周上机项目2用文件保存的学生名单
- 2015年最佳的15个 Node.js 开发工具
- C++打开指定文件夹,并选中文件
- WKWebView 在64位设备上的白屏问题
- 讨论UML概念和模型UML九种图。
- WKWebView 在64位设备上的白屏问题
- JavaScript 自定义对象
- Table动态增加删除行
- 第13周-阅读项目3-对文本文件的访问
- 6.5 UITabBarController
- Climbing Stairs
- Javascript:谈谈JS的全局变量跟局部变量(转zyz511919766)