第十六周--阅读程序
2016-06-18 19:28
155 查看
问题及代码:
#include <iostream> #include <cstdlib> #include <fstream> // (1) using namespace std; int main() { fstream file; file.open("abc.txt", ios::in); // (2) if(!file) { cout<<"abc.txt can’t open."<<endl; exit(1); } char ch; int i=0; while(file.get(ch)) // (3) { ++i; // (4) } cout<<"Character: "<<i<<endl; file.close();// (5) return 0; }
运行结果:
<img src="http://img.blog.csdn.net/20160618192750626?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQv/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center" alt="" />
相关文章推荐
- Linux hostname对Oracle实例以及监听的影响
- FFMPEG类库打开流媒体的方法(需要传参数的时候)
- 【VS开发】【DSP开发】TCP和UDP数据包结构
- 349. Intersection of Two Arrays
- php中异常处理方法
- 加载一张高德地图
- pcDuino 3b安装OpenCV3.1.0
- pcDuino 3b安装OpenCV3.1.0
- [Android]Android之解析zip
- 译码器的定义及功能
- B树的插入与查找
- 关于ng-router嵌套使用和总结
- 268MissingNumber
- java读书笔记
- 剑指offer(39)-和为S的两个数字
- elasticsearch java 增删改查 版本1
- java中 类和对象
- 一键收藏到GitHub
- 数组
- Codeforces Round #358 (Div. 2) Alyona and Strings