|
Problem summary: serialization saves double-precision data, decimal, newline, space
The code is as follows, my data is saved in a collection class m_SelPtList, which has three member variables (respectively X, Y, Z three coordinate values, the type is double), what I saved in this way is a binary format file, I would like to ask how to convert to decimal display format (that is, what is saved in the file is decimal).
CFile file("1.txt",CFile::modeCreate | CFile::modeWrite);
CArchive ar(&file,CArchive::store);
int iCount=Spt.m_SelPtList.GetSize();
for(int i=0;i<iCount;i++)
{
ar<<m_SelPtList[i]->x<<m_SelPtList[i]->y<<m_SelPtList[i]->z;
}
In the file, I hope to save it as follows: each line represents a point, and the coordinates of each point are separated by spaces to store the X, Y, and Z coordinates. As shown below:
-2.372417e+02 -4.032650e+01 -5.574990e+01//click one
-2.260712e+02 -4.186780e+01 -5.933653e+01//point two
How can I save in a new line in serialization? A space separates each value? How to write a better code for opening this file? |
|