将CString字符串(包含中文,字母,数字等)输出到指定路径txt文件:CStringdata=_T(“你的内容”);//导入字符串 data.Replace(_T("\r"),_T("\r\n"));//替换为window使用的回车换行CStringstr= _T("D://2.txt");//定义生成txt的路径CFilefile(str,CFile::modeCreate| CFile::modeWrite);//定义filefile.SeekToBegin();file.Write("\xff\xf e",2);//二进制写入格式file.Write(data,data.GetLength()sizeof(wchar_t) );//写入file.Flush();file.Close();//完成关闭//将Char型字符导出到txtcharstr[_C VTBUFSIZE];;stringcombined;//获取字符ofstreamfout;//打开或新建stringstr eamss;//合并字符intd=0;//导出1212的矩阵格式fout.open("F:\\U.txt");for( inti=0;i<12;i++){for(intj=0;j<12;j++){doublea=U .get(i,j);//获取矩阵数组元素d++;_gcvt_s(str,_CVTBUFSIZE,a,15);//将doub le(int)转为charif(d<12){ss<d=0;ss<符组fout<
|
|