VC MFC 字符串写入txt

2024-11-15 15:38:08
推荐回答(3个)
回答(1):

在工程配置中选择:多字节字符集!


回答(2):

你的工程是UNICODE型的,所以要用WCHAR数组。我帮你改了,你试试:
WCHARname[4][5]={L"nums",L"leng",L"fade",L"step"};
double num[4]={1.342,2.235,3.644,4.678};
int i=0;
CFile fout;
CString gs,f;
fout.Open(_T("D:\\TEXT.txt"),CFile::modeCreate|CFile::modeWrite);
gs=CString(_T("set%s=%f\r\n"));
for(i=0;i<4;i++)
{
f.Format(gs,name[i],num[i]);
fout.Write(f,f.GetLength());
}
fout.Close();

回答(3):

CStdioFile m_fileW;
m_fileW.Open( "D:\\TEXT.txt", CFile::modeNoTruncate|CFile::modeReadWrite)
m_fileW.SeekToEnd();
m_fileW.WriteString("sssssssr\n");