#include <iostream>
#include <fstream>
#include <cstdlib>
const int SIZE=20;
using namespace std;
int main()
{
char filename[SIZE];
char ch;
ifstream inFile;//inFile 是有一个ifstream对象
cout<<"Enter name of file: ";
cin.get(filename,SIZE);
inFile.open(filename);//inFile用来读取Lynn.txt文件
if(!inFile.is_open())
{
cout<<"Could not open the file "<<filename<<endl;
cout<<"Program terminating.\n";
exit(EXIT_FAILURE);
}
double count=0;
inFile>>ch;
while(inFile.good())
{
++count;
inFile>>ch;
}
if(inFile.eof())
cout<<"End of file reached.\n";
else if(inFile.fail())
cout<<"Input terminated by char mismatch.\n";
else
cout<<"Input terminated for unknown reason.\n";
if (count==0)
cout<<"No char processed.\n";
else
cout<<"Items read: "<<count<<endl;
inFile.close();
system("pause");
return 0;
}

编程菜鸟的日记-初学尝试编程-C++ Primer Plus 第6章编程练习8的更多相关文章

  1. 编程菜鸟的日记-初学尝试编程-C++ Primer Plus 第6章编程练习9

    #include <iostream> #include <fstream> #include <cstdlib> #include <string> ...

  2. 编程菜鸟的日记-初学尝试编程-C++ Primer Plus 第6章编程练习7

    #include <iostream> #include <string> #include <cctype> using namespace std; int m ...

  3. 编程菜鸟的日记-初学尝试编程-C++ Primer Plus 第6章编程练习6

    #include <iostream> #include <string> using namespace std; const int MSIZE=100; struct j ...

  4. 编程菜鸟的日记-初学尝试编程-C++ Primer Plus 第6章编程练习5

    #include <iostream> using namespace std; const double N1=35000; const int N2=15000; const int ...

  5. 编程菜鸟的日记-初学尝试编程-C++ Primer Plus 第6章编程练习4

    #include <iostream> using namespace std; const int strsize=30; const int BOPSIZE=5; void showm ...

  6. 编程菜鸟的日记-初学尝试编程-C++ Primer Plus 第6章编程练习3

    #include <iostream> using namespace std; void showmenu(void) { cout<<"Please enter ...

  7. 编程菜鸟的日记-初学尝试编程-C++ Primer Plus 第6章编程练习2

    #include <iostream> #include <cctype> using namespace std; const int MAXSIZE=10; int mai ...

  8. 编程菜鸟的日记-初学尝试编程-C++ Primer Plus 第6章编程练习1

    #include <iostream>#include <cctype>using namespace std;int main(){ char ch; while((ch=c ...

  9. 编程菜鸟的日记-初学尝试编程-C++ Primer Plus 第5章编程练习9

    #include <iostream>using namespace std;int main(){ int num; cout<<"Enter number of ...

随机推荐

  1. Contest2162 - 2019-3-28 高一noip基础知识点 测试5 题解版

    传送门 T1 单调栈 按照b排序 在家每一个物品时,判断一下a和b的关系 如果s[sta[top]].a>=s[i].b,就弹栈 记录所有时候的height,并取最大值 T2 单调栈裸题 单调栈 ...

  2. 中文 Tex

    \documentclass{article} \usepackage{ctex} \begin{document} 中文English \[E = m c^2\] \end{document} \d ...

  3. c++ 常用头文件

    1.#include<iostream> iostream 的意思是输入输出流.#include<iostream>是标准的C++头文件,任何符合标准的C++开发环境都有这个头 ...

  4. adb devices 找不到设备

    问题如图: 解决方法: 1.在开发人员选项中,找到USB调试,打开USB调试 2.如果还不行,下载360手机助手,连接手机,会自动安装驱动 3.再次adb devices,OK

  5. Linux启动activemq失败

    第一种情况: 在网上查找错误,通过./activemq console命令可以查看到activemq启动的错误信息,另外在data/activemq.log文件中可以查看到错误日志. java.io. ...

  6. PMI-ACP练习题知识积累-打印版

    敏捷铁三角的参数:价值,质量,约束.传统的铁三角包括的参数是范围,进度和成本 敏捷计划的三个主要层级为:发布计划,迭代计划,每日计划 敏捷开发模型的特征包括 开发由多个迭代组成. 敏捷拥抱不确定性,而 ...

  7. 解决多个py模块调用同一个python的logging模块,打印日志冲突问题

    前期对python中的logging模块进行了封装,这样自动化测试框架中的多个测试脚本(py)就可以使用同一个封装后的日志系统,这样各脚本中只需要引用一下即可,方面快捷.那么当我使用unittest框 ...

  8. Timeline扩展功能实践指南

    转载于http://forum.china.unity3d.com/forum.php?mod=viewthread&tid=32842,介绍了timeline的轨道扩展 Timeline功能 ...

  9. 使用freemarker模板引擎生成word文档的开发步骤

    1.准备模板文档,如果word文档中有表格,只保留表头和第一行数据:2.定义变量,将word文档中的变量用${var_name}替换:3.生成xml文件,将替换变量符后的word文档另存为xml文件: ...

  10. 【转】Python——读取html的table内容

    Python——python读取html实战,作业7(python programming) 查看源码,观察html结构 # -*- coding: utf-8 -*- from lxml.html ...