编程菜鸟的日记-初学尝试编程-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 ...
随机推荐
- REM方案总结
flexible.js方案 1.设置根元素字体大小为屏幕宽度的十分之一. 2.即根元素字体大小与屏幕宽度的比例为:1/10. jQuery.weui的rem设计方案 1.以屏幕宽度375px为基础,根 ...
- python数字常量
数学常量 pi 数学常量 pi(圆周率,一般以π来表示) e 数学常量 e,e即自然常数(自然常数).
- static关键字特点
目录 static关键字特点 静态代码块 static修饰与非static修饰的区别 static关键字特点 随着类的加载而加载 static修饰的变量和方法都会放在方法区中静态区,是属于类的. 静态 ...
- Django-CSRF,AJAX,FORM
内容总览1.CSRF相关1>CSRF源码分析2>ajax的实现(ajax的实例(异步计算,参数测试,上传))3>ajax通过csrf的校验 2.FORM组件1>基本使用2> ...
- react給變量賦值并列元素
今天在使用react時發現一個問題:我在給一個變量賦值多個元素,但不能用div包含起來. 如: var p = <div> <p></p> <p>< ...
- 【原创】大数据基础之Logstash(5)监控
有两种方式来监控logstash: api ui(xpack) When you run Logstash, it automatically captures runtime metrics tha ...
- P2757 [国家集训队]等差子序列
P2757 [国家集训队]等差子序列 题目传送门 推荐一篇好题解 此题要求我们在一个序列中找出一个等差子序列. 显然,我们只需要考虑子序列长度len=3的情况,因为在长度为4的子序列中必定有一个长度为 ...
- 关于element-ui表单验证(自定义验证规则)
<el-form :model="ruleForm" :rules="rules" ref="ruleForm" label-widt ...
- tcp与ip协议的区别
TCP/IP(TransmissionControlProtocol/InternetProtocol的简写,中文译名为传输控制协议/互联网络协议). 简单地说,就是由底层的IP协议和TCP协议组成的 ...
- netstat、ps、top 、kill 命令备忘
1.ps命令用于显示当前进程 (process) 的状态. -aux 显示所有包含其他使用者的行程. -e 显示所有进程. -f 全格式输出. 一般带参数 -ef 或者 -aux ,差别不大. 区别: ...