我要把一个数组内容写到一个文件 中,但是输出的都是怪字符,不知道怎么办,请各位大虾指点一下,非常感谢!!
具体代码如下:
CFile mFile(_T("a.txt "), CFile::modeWrite|CFile::modeCreate);
mFile.Write(temp,model->faceCnt * 3);
mFile.Flush();
mFile.Close();
temp 为float 数组。
具体代码如下:
CFile mFile(_T("a.txt "), CFile::modeWrite|CFile::modeCreate);
mFile.Write(temp,model->faceCnt * 3);
mFile.Flush();
mFile.Close();
temp 为float 数组。
const void* lpBuf,//A pointer to the user-supplied buffer that contains the data to be written to the file
UINT nCount
);
for (int i = 0; i < 3; i++)
{
CString strFloat;
strFloat.Format(TEXT("%5.2f\r\n"), temp[i]);//格式化一下
mFile.Write(strFloat.GetBuffer(), strFloat.GetLength());
strFloat.ReleaseBuffer();
}
mFile.Close();这样输出之后,你用记事本就可以打开看到你的数组里面的数据了!呵,QQ539929779
temp 为float 数组。
要是需要在文本中看出有效字符的话,格式成字符串。读入的时候按字符串读入,然后转化成数字就行。