#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. Laravel框架中打印sql

     在使用Laravel框架的时候,调试的时候,需要将查询的SQL输出校验,这是需要将SQL打印出来. 一.方法 DB::connection()->enableQueryLog();  // 开 ...

  2. java错误分类

    IllegalArgumentException 回直接crashError

  3. xls 打乱序列 -和给拼接字符串加上双引号

    打乱  给空列 添加函数 =RAND() ,下拉,排序,即可打乱 添加双引号: =""""&C1&"""" ...

  4. MySQL1:客户端/服务器架构

    一.MySQL的客户端/服务器架构 前言 之前对MySQL的认知只限于会写些SQL,本篇算是笔记,记录和整理下自己对MySQL不熟悉的地方. 大致逻辑: MySQL的服务器程序直接和我们存储的数据打交 ...

  5. 11:57:24 [org.springframework.kafka.KafkaListenerEndpointContainer#0-0-C-1] WARN o.apache.kafka.clients.NetworkClient - [Consumer clientId=consumer-2, groupId=jiatian_api] 3 partitions have leader……

    错误如下: 11:57:24 [org.springframework.kafka.KafkaListenerEndpointContainer#0-0-C-1] WARN  o.apache.kaf ...

  6. F - JDG HDU - 2112 (最短路)&& E - IGNB HDU - 1242 (dfs)

    经过锦囊相助,海东集团终于度过了危机,从此,HDU的发展就一直顺风顺水,到了2050年,集团已经相当规模了,据说进入了钱江肉丝经济开发区500强.这时候,XHD夫妇也退居了二线,并在风景秀美的诸暨市浬 ...

  7. STM32 USB 鼠标+键盘 串口控制

    *MOS0101000000# 鼠标左键按下 *MOS0102000000# 鼠标右键按下 *MOS0103000000# 鼠标中键按下 *MOS0100000000# 鼠标抬起 *MOS01000a ...

  8. OpenStack--Rabbitmq组件消息队列

    概念 队列 MQ 全称为Message Queue,消息队列( MQ ) 是一种应用程序的通信方法.应用程序通过读写入列队的消息(针对应用程序的数据)来通信,而无需专用连接来链接它们. 消息传递指的是 ...

  9. 认识 Linux 文件权限

    Linux 之所以是比较安全的操作系统,和它丰富的文件权限设定是有关系的,学习 Linux 操作系统一定要懂文件的权限识别和设置.通过这篇博文我们了解 Linux 操作系统的文件权限. 拥有者  / ...

  10. leetcode python最长回文子串

    回文的意思是正着念和倒着念一样,如:上海自来水来自海上,雾锁山头山锁雾,天连水尾水连天 给定一个字符串 s,找到 s 中最长的回文子串.你可以假设 s 的最大长度为 1000. 示例 1: 输入: & ...