CFile fText;
CFileException e;
CString str; try
{
if(!fText.Open(_T("Test.txt"), CFile::modeCreate|CFile::modeWrite/*|CFile::typeText*/, &e))
{
throw &e;
}


str = _T("<3>\"星际争霸\"");
fText.Write(str, str.GetLength());

fText.Close();
}
catch (CFileException *e) 
{
TCHAR errorMsg[256];
e->GetErrorMessage(errorMsg, 256, NULL); str.Format(_T("%s"), errorMsg);
AfxMessageBox(str);
}
如何使这段中文正确的输入到txt文本中或者给个例子哈  [email protected]谢谢了

解决方案 »

  1.   

    直接写就行了。
    或者你使用CStdioFile,WriteString
      

  2.   

    谢谢ouyh12345哈已经解决了写的问题那读数据的也是先用char读,再转化为unicode么?比方说文本文件里面的内容如下
    "啊阿埃挨哎唉哀皑癌蔼矮艾碍爱隘"
    我如何确保我每次都是读一个字呢?
      

  3.   

    如果是unicode的话,可以这样,先在文本文件中写入0xFF0xFE,表示是unicode文本文件.存的时候就按照unicode文本方式存,读也是读取unicode文本.