晕一把.写应用程序了...
字符串的转化:
float to char
char *cTem;
float fZhe;
sprintf(cTem,"%.3f\0",fZhe);
char to float
用atof()就搞定
char to CString
CString.Format("%s",cTem);
字节对齐问题:#pragma pack(2) //2字节对齐
2进制文件读写:
读:
CFile MyFile;
MyFile.Open(strValue,CFile::modeRead|CFile::typeBinary|CFile::shareDenyNone);
int len = sizeof(Record);
MyFile.Seek(0,CFile::begin);
MyFile.Read(&Record,len);
写:
CFile MyFile;
int len = sizeof(Record);
byte bTem[346];
memcpy(bTem,&Record,346);
MyFile.Remove(strValue);
MyFile.Open(strValue,CFile::modeRead|CFile::typeBinary|CFile::shareDenyNone|CFile::modeCreate|CFile::modeWrite);
MyFile.Write(bTem,346);
MyFile.Close();