编程菜鸟的日记-初学尝试编程-C++ Primer Plus 第6章编程练习8
#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的更多相关文章
- 编程菜鸟的日记-初学尝试编程-C++ Primer Plus 第6章编程练习9
#include <iostream> #include <fstream> #include <cstdlib> #include <string> ...
- 编程菜鸟的日记-初学尝试编程-C++ Primer Plus 第6章编程练习7
#include <iostream> #include <string> #include <cctype> using namespace std; int m ...
- 编程菜鸟的日记-初学尝试编程-C++ Primer Plus 第6章编程练习6
#include <iostream> #include <string> using namespace std; const int MSIZE=100; struct j ...
- 编程菜鸟的日记-初学尝试编程-C++ Primer Plus 第6章编程练习5
#include <iostream> using namespace std; const double N1=35000; const int N2=15000; const int ...
- 编程菜鸟的日记-初学尝试编程-C++ Primer Plus 第6章编程练习4
#include <iostream> using namespace std; const int strsize=30; const int BOPSIZE=5; void showm ...
- 编程菜鸟的日记-初学尝试编程-C++ Primer Plus 第6章编程练习3
#include <iostream> using namespace std; void showmenu(void) { cout<<"Please enter ...
- 编程菜鸟的日记-初学尝试编程-C++ Primer Plus 第6章编程练习2
#include <iostream> #include <cctype> using namespace std; const int MAXSIZE=10; int mai ...
- 编程菜鸟的日记-初学尝试编程-C++ Primer Plus 第6章编程练习1
#include <iostream>#include <cctype>using namespace std;int main(){ char ch; while((ch=c ...
- 编程菜鸟的日记-初学尝试编程-C++ Primer Plus 第5章编程练习9
#include <iostream>using namespace std;int main(){ int num; cout<<"Enter number of ...
随机推荐
- CentOS 6.6 系统升级到 CentOS 6.7
1.利用Centos6.7 ISO镜像挂载为本地镜像 创建一个挂载目录 CentOS 6.6 系统升级到 CentOS 6.7 mkdir /mnt/data 2.挂载镜像(远程镜像) mount - ...
- ztree树应用
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="ZtreeListVi ...
- solr7.5--win10--部署使用
2018年8月份学习使用solr,当时下载的版本是solr7.5,写这篇博文的时候是2019年3月份,solr此时已经出到了8.0版本.一个大版本的变迁肯定有很多的改动,暂时还未研究就不赘述了. 此篇 ...
- 切换npm源地址
全局安装nrm (npm源管理工具) npm install -g nrm 查看所有的源地址 * 代表当前的源地址 nrm ls * npm ----- https://registry.npmj ...
- 2018-2019-2 20165325 《网络对抗技术》 Exp6 信息搜集与漏洞扫描
2018-2019-2 20165325 <网络对抗技术> Exp6 信息搜集与漏洞扫描 实验内容(概要) 1 各种搜索技巧的应用: 2 DNS IP注册信息的查询: 3 基本的扫描技术 ...
- anylogic 使用
1.智能体群的用法有人会问:请问怎么给生成的两个对象赋予属性,比如在分叉的时候一个进入sink1,另一个进入sink2?我想source生成不同的实体,而且各个实体都有不同的属性,请问应该怎么设置呢? ...
- MySQL:参数wait_timeout和interactive_timeout以及空闲超时的实现【转】
一.参数意思 这里简单解释一下两个参数,含义如下: interactive_timeout:The number of seconds the server waits for activity on ...
- 修改Maven仓库路径
我自己新建的地址:D:\apache-maven-3.6.0\repository 找到:localRepository,修改为自定义的位置 在IDEA里面进行配置 这样项目的maven仓库地址就修改 ...
- unity 使用RotateAround的使用注意
1.对于一个固定的点,围绕它进行旋转.需要注意区分世界坐标还是本地坐标 RotateAround(GameObject.Find("Cave").transform.positio ...
- python3解决 json.dumps中文乱码
使用json.dumps()运行结果如下 role_name字段中文乱码了 只需要使用ensure_ascii=False 运行结果如下: