写数据入文件,打开却是乱马
数字的计算应该没问题(pVData[i]每个数都转换症正确,
假设pVData[0]=7.876),
就是要写入VData.txt文件是可能是个是不对。
不知道怎么改,请教
代码如下:
CFile tfile;
char* pFileName = "2005年12月15日22时34分32秒.dat";
if(tfile.Open(pFileName,CFile::modeRead))
{
WORD word;
double* pVData = new double[1024];//digital
CString* pstr = new CString[1024];//charecter
tfile.Seek(60,CFile::begin);
for(int i=0;i<1024;i++)
{
pVData[i] = 0.0;
tfile.Read(&word,2);
word = word/16;
if(word >= 2048)
pVData[i] = (-1)*(word-2048)*10.0/4096;
else
pVData[i] = word*10.0/4096;
pstr[i].Format("%f\n",pVData[i]);//可能有问题
} //
tfile.Close();
tfile.Open("VData.txt",CFile::modeWrite);
tfile.Write(pstr,2048);
tfile.Close();
}
else
{
MessageBox("File Open Failed!","ERROR",MB_OK|MB_ICONWARNING);
}