文件的读写
来源:互联网 发布:mac系统下载栏不是扇形 编辑:程序博客网 时间:2024/05/20 21:19
**#include <iostream>#include <fstream>using namespace std;void save_to_file(){ofstream outfile("f2.dat");if(! outfile){cerr<<"open f2.dat error!"<<endl;exit(0);} char c[80]; cin.getline(c,80); for(int i=0;c[i]!=0;i++) { if (c[i] >= 65 && c[i] <= 90 || c[i] >= 97 && c[i] <= 122) { outfile.put(c[i]); cout << c[i]; } } cout<<endl; outfile.close();}void get_from_file(){ char ch; ifstream infile("f2.dat",ios::in); if(! infile) { cerr<<"open f2.dat error!"<<endl; exit(0); } ofstream outfile("f3.dat"); if(! outfile) {cerr<<"open f3.dat error!"<<endl; exit(0); } while(infile.get(ch)) { if(ch>=97&&ch<=122)ch=ch-32; outfile.put(ch); cout<<ch; } cout<<endl; infile.close(); outfile.close();}int main(){ save_to_file(); get_from_file(); return 0;}#include <iostream>#include <fstream>using namespace std;void save_to_file(){ofstream outfile("f2.dat");if(! outfile){cerr<<"open f2.dat error!"<<endl;exit(0);} char c[80]; cin.getline(c,80); for(int i=0;c[i]!=0;i++) { if (c[i] >= 65 && c[i] <= 90 || c[i] >= 97 && c[i] <= 122) { outfile.put(c[i]); cout << c[i]; } } cout<<endl; outfile.close();}void get_from_file(){ char ch; ifstream infile("f2.dat",ios::in); if(! infile) { cerr<<"open f2.dat error!"<<endl; exit(0); } ofstream outfile("f3.dat"); if(! outfile) {cerr<<"open f3.dat error!"<<endl; exit(0); } while(infile.get(ch)) { if(ch>=97&&ch<=122)ch=ch-32; outfile.put(ch); cout<<ch; } cout<<endl; infile.close(); outfile.close();}int main(){ save_to_file(); get_from_file(); return 0;}**
随机访问二进制数据文件
0 0
- 串口的读写,文件读写
- INI文件的读写
- 读写文件的例子
- INI文件的读写
- 关于文件的读写
- 文件的读写操作
- 文件的读写操作
- properties文件的读写
- 读写服务器端的文件
- 位图文件的读写
- C++文件的读写
- ini文件的读写
- 文件的读写
- 自定义文件的读写
- 文件的读写操作
- 文件的读写
- 文件读写的问题
- Python文件的读写
- Javascript的this用法
- 华为代码风格要求
- eclipse-git 插件
- 算法学习之动态规划(leetcode 85. Maximal Rectangle)
- spring mvc 导出Excel
- 文件的读写
- Spring系列之Spring常用注解总结
- Ubuntu16.04将python2切换为python3
- 排序之堆排序
- 最大子数组
- 史上最全的SpringMVC学习笔记
- 腾讯代码风格要求
- 求交集
- Web前端面试