您的位置:首页 > 其它

对文件读取以及写入的一个小例子

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;

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐