对文件读取以及写入的一个小例子
2013-09-28 21:08
288 查看
// container.cpp : 定义控制台应用程序的入口点。
//
#include "stdafx.h"
#include<fstream>
#include<iostream>
#include<string>
#include<stdexcept>
#include<vector>
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
string a="in.txt";
string b="out.txt";
ifstream infile(a.c_str());
if(infile)
{
cout<<"哟,竟然这个输入文件存在这里"<<endl;
string ingood;
infile>>ingood;
cout<<ingood<<endl;
}
ofstream outfile(b.c_str(),ofstream::app);
if(outfile)
{
string outname="这是我要输出的东西哦";
outfile<<outname;
}
return 0;
}
//
#include "stdafx.h"
#include<fstream>
#include<iostream>
#include<string>
#include<stdexcept>
#include<vector>
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
string a="in.txt";
string b="out.txt";
ifstream infile(a.c_str());
if(infile)
{
cout<<"哟,竟然这个输入文件存在这里"<<endl;
string ingood;
infile>>ingood;
cout<<ingood<<endl;
}
ofstream outfile(b.c_str(),ofstream::app);
if(outfile)
{
string outname="这是我要输出的东西哦";
outfile<<outname;
}
return 0;
}
相关文章推荐
- python读取CSV文件以及“写入CSV致文件每一行后面会多一个空行”问题解决
- 如何从内核模式设备驱动程序中打开一个文件以及如何读取或写入文件
- 如何从内核模式设备驱动程序中打开一个文件以及如何读取或写入文件(来自微软官网)
- 一个模式字符串,一个替换用字符串,以及两个文件名 它应该读取第一个文件, 并将内容写入第二个文件
- 【转帖】如何从内核模式设备驱动程序中打开一个文件以及如何读取或写入文件
- java中的文件读取和文件写出:如何从一个文件中获取内容以及如何向一个文件中写入内容
- 一个java读取word文档并将其写入xml文档的例子
- C++学习--向txt文件写入数据、读取数据、获取行数以及删除文件
- 读出一个文本文件,并在前面加上行号后,写入到另一个文件的简单例子
- Python 创建、读取和写入文件以及yield关键字- 千月的python linux 系统管理指南学习笔记(14)
- 自己在看一些android教学视频后,整理的一个文件读取和写入类
- 一个简单但详细的解释Windows文件映射读取数据文件的例子
- 读取EXCEL。POI的一个死坑。。文件的流不能close以及删除
- 如何读取一个文件并将内容写入一个新文件中
- Properties配置文件读取/写入例子
- 读取一个文件写入另一个文件
- 【转载】关于:读写xls文件,提供下载的一个小例子(jxl 的简单运用) - 读取文件
- java字节流的方式复制一个文件,按数组读取和写入
- android(安卓)sd卡写入 读取文件的例子
- 以Android L读取系统所有logcat并写入文件为例分析Android 以添加系统进程的方式申请selinux的权限执行shell脚本,以及avc:dined应该怎么申请权限