1:创建文本并写入数据
string strPath = "D:\\Tmp\\test.txt";
ofstream ofsTest(strPath, ios_base::app);
int nFirst = 0;
int nSecond = 1;
ofsTest<<"第一个数字:"<<nFirst<<" ";
ofsTest<<"第二个数字:"<<nSecond<<" ";
ofsTest<<endl;
2:检测文本是否存在
fstream _file;
_file.open("D:\\Tmp\\test.txt");
if(!_file)
{
//如果不存在,进行提示
}