C++文件流操作
来源:互联网 发布:淘宝优惠劵网站源码 编辑:程序博客网 时间:2024/06/07 08:45
#include "stdafx.h"
#include <string>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdlib>
using namespace std;
void writeCharsetToFile(const string& filename);
void outputFile(const string& filename);
int _tmain(int argc, _TCHAR* argv[])
{
writeCharsetToFile("charset.out");
outputFile("charset.out");
system("pause");
return 0;
}
void writeCharsetToFile(const string& filename)
{
//open output file
ofstream file(filename.c_str());
//file opened?
if(!file){
//No, abort program
cerr<<"can't open output file/""<<filename<<"/""<<endl;
exit(EXIT_FAILURE);
}
//write character set
for(int i=32;i<256;i++)
{
file<<"value: "<<setw(3)<<i<<" "
<<"char: "<<static_cast<char>(i)<<endl;
}
}//close file automatically
void outputFile(const string& filename)
{
//open input file
ifstream file(filename.c_str());
//file opened?
if(!file){
//No,abort program
cerr<<"can't open input file/""<<filename<<"/""<<endl;
exit(EXIT_FAILURE);
}
//copy file contents to cout
char c;
while(file.get(c)) { cout.put(c);}
}//close file automatically
- 【C/C++】文件流操作
- C流式文件操作
- Objective-C文件流操作
- C#IO流文件操作
- [C/C++]文件操作
- 文件操作--C 函数操作
- C基于流fstream的文件操作
- C/C++流操作(文件,字符串)
- 文件的流操作(C)
- C基于流fstream的文件操作
- C语言文件流操作函数大全
- 基本文件流操作(C语言)
- c文件操作
- C文件操作
- C的文件操作
- c语言文件操作
- C的文件操作
- 标准C文件操作
- 靳氏DIV布局兼容“武林秘诀”
- javascript的小括号
- 借助内存表处理复杂的oracle查询要求
- Debugs
- PetShop 缓存技术
- C++文件流操作
- Windows服务应用程序
- 操作系统历史列表
- IT文章
- SQL Server2005的固定数据库角色
- 在pldeveloper中输出超过255个的字符串
- Java基于Socket文件传输示例
- 端午粽香艺更馨-2009CSDN南昌俱乐部聚会成功举办-附精彩图片
- 怎么 在客户端 验证 self-signed 证书. -- FTPS