编程菜鸟的日记-初学尝试编程-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 ...
随机推荐
- java中的标识符、修饰符、关键字
关键字的特点:1.完全小写的字母,2,在增强版记事本中有特殊颜色 例如@是电子邮箱当中有特殊含义的.被保留的.不能随意使用的字符,关键字. 例如图中public.class.static.void是关 ...
- 深入理解python装饰器
写在前面,参考文章链接: 1.博客园(https://www.cnblogs.com/everzin/p/8594707.html) 2.公众号文章 装饰器是什么,什么时候会用到装饰器呢? 写代码要遵 ...
- centos7 nginx配置ssl证书实现https访问同时http访问
1,首先将你申请到的nginx 分类下的ssl证书上传到nginx的config下(可以新建一个目录叫ssl.) 2.修改nginx的config配置 server {listen 80;(监听80端 ...
- 区别 chown和chmod的用法
本人总是习惯使用chmod,而把chown混淆. chown就是修改 第一列内容的 ,chmod是修改 第3,4列内容的. chown用法用来更改某个目录或文件的用户名和用户组的chown 用户名:组 ...
- python中的多线程和多进程编程
注意:多线程和多线程编程是不同的!!! 第一点:一个进程相当于一个要执行的程序,它会开启一个主线程,多线程的话就会再开启多个子线程:而多进程的话就是一个进程同时在多个核上进行: 第二点:多线程是一种并 ...
- Shell-仅保留最近3天的备份文件: find . -name "*.sql" -mtime +3 -ls -exec rm {} \;
Code: find . -name "*.sql" -mtime +3 -ls -exec rm {} \;
- 使用python爬虫,批量爬取抖音app视频(requests+Fiddler+appium)
抖音很火,楼主使用python随机爬取抖音视频,并且无水印下载,人家都说天下没有爬不到的数据,so,楼主决定试试水,纯属技术爱好,分享给大家.. 1.楼主首先使用Fiddler4来抓取手机抖音app这 ...
- 结合jira搭建自动化测试平台
mysql 语句查看 python manage.py sqlmigrate your_app_name 0001 代码如下 #coding=utf8 #https://jira.readthedoc ...
- Python 并发编程
进程 开启进程 from multiprocessing import Process import time def task(name): print('%s is running' %name) ...
- 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 ...