第15周项目1-小玩文件(1)
2016-06-16 08:56
176 查看
/* *Copyright(C) 2016,计算机与控制工程学院 *All rights reserved. *文件名:cpp.cpp *作者:张志新 *完成日期:2016年6月16日 *版本号:v1.0 *问题描述:文件小试,把文件补充完整。 */ #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;//输出的i比文件字节大小多1 file.close;// (5) return 0; }
相关文章推荐
- Hello, Python!
- Merge Sorted Array
- Java使用JavaMail API发送和接收邮件的代码示例
- 满足条件的整数对个数
- 浅谈firefox 的event事件处理
- Xml中SelectSingleNode方法,xpath查找某节点用法
- Web Service
- 项目2-洗牌(3)
- 非3D Touch的设备上模拟Peek Preview效果
- netty4.0.23 简单demo
- Android使用switch模块进行GPIO口检测(二)-->Android内核部分
- typedef
- python数据类型详解
- ssh登录docker容器
- [李景山php]每天laravel-20160901|Dispatcher-1
- Debian8.5下cinnamon just crashed running in fallback mode的解决方案
- 路径标记语法
- Ionic入门二:网格(Grid)页面布局
- js实现模态窗口的拖拽功能
- 全面理解JavaScript中的继承(必看)