实例代码:
#include "stdafx.h"
#include <iostream>
#include <fstream>
#include <io.h>
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
//文件中追加文本内容
string strpath3 = "D:\\Dtest5\\Readjpg\\3.txt";
std::ofstream fout3(strpath3.c_str(), ios::app);
char * pwt = "abc";
cout<<strlen(pwt)<<endl;
fout3.write(pwt, sizeof(char) * strlen(pwt));
fout3.close();
return 0;
}
string strpath3 = "EmrData\\temp99.txt";
std::ofstream out;
out.open(strpath3.c_str(), ios::app);
out<<"lalalal"<<endl;
out.close();
strpath3 = "EmrData\\temp999.txt";
out.open(strpath3.c_str(), ios::app);
out<<"lalalal"<<endl;
out.close();