Click here to Skip to main content
16,014,294 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralCArray woes Pin
raner25-Dec-02 23:05
raner25-Dec-02 23:05 
GeneralRe: CArray woes Pin
KaЯl25-Dec-02 23:24
KaЯl25-Dec-02 23:24 
GeneralRe: CArray woes Pin
raner26-Dec-02 7:00
raner26-Dec-02 7:00 
GeneralRe: CArray woes Pin
KaЯl26-Dec-02 7:26
KaЯl26-Dec-02 7:26 
GeneralRe: CArray woes Pin
raner26-Dec-02 22:21
raner26-Dec-02 22:21 
GeneralRe: CArray woes Pin
KaЯl26-Dec-02 22:36
KaЯl26-Dec-02 22:36 
GeneralRe: CArray woes Pin
raner26-Dec-02 22:49
raner26-Dec-02 22:49 
GeneralRe: CArray woes Pin
KaЯl26-Dec-02 23:20
KaЯl26-Dec-02 23:20 
I suppose your Serialize method is like
void CRainAttDoc::Serialize(CArchive& ar)<br />
{<br />
CString strOneLine; <br />
<br />
while(ar.ReadString(strOneLine)) <br />
{ <br />
SRawData *pData = new SRawData;<br />
sscanf(strOneLine,"%g%g\n",pData->x,pData->y); <br />
m_array1.Add(pData); <br />
} <br />
}


First of all, you should test if you are writing or reading, using ar.IsStoring() (Serialization works both way). Also instead using a "while" statement, I would suggest you to write explicitly at the beginning of the archive the number of items to read
It would look like this

void CRainAttDoc::Serialize(CArchive& ar)<br />
{<br />
     if(ar.IsStoring()){<br />
          // writing the data<br />
          int iSize = m_array1.GetSize();<br />
          ar << iSize;<br />
          for(int i = 0; i w iSize; i++){<br />
               // write each element here in the archive<br />
               ...<br />
          }<br />
     }else{<br />
          // reading the data<br />
          m_array1.RemoveAll();<br />
<br />
          int iSize;<br />
          ar >> iSize;<br />
          m_Array1.SetSize(iSize);<br />
          for(int i = 0; i < iSize; i++){<br />
               // read one element here and add it to the array<br />
               ...<br />
          }<br />
     }<br />
}


I'm not absolutly sure of the syntax, I write it from memory Smile | :)

HTH,

K.






One small village of indomitable geeks still holds out against the invaders. And life is not easy for the managers legionaries who garrison the fortified camps of Microsoftum, Javum, Ceplumplum and Vebasum

GeneralRe: CArray woes Pin
raner27-Dec-02 5:06
raner27-Dec-02 5:06 
GeneralRe: CArray woes Pin
KaЯl27-Dec-02 5:13
KaЯl27-Dec-02 5:13 
GeneralRe: CArray woes Pin
raner27-Dec-02 6:22
raner27-Dec-02 6:22 
GeneralRe: CArray woes Pin
KaЯl27-Dec-02 12:47
KaЯl27-Dec-02 12:47 
GeneralRe: CArray woes Pin
Roman Fadeyev26-Dec-02 0:05
Roman Fadeyev26-Dec-02 0:05 
GeneralRe: CArray woes Pin
raner26-Dec-02 6:38
raner26-Dec-02 6:38 
GeneralRe: CArray woes Pin
Christian Graus26-Dec-02 0:11
protectorChristian Graus26-Dec-02 0:11 
GeneralRe: CArray woes Pin
User 665826-Dec-02 0:41
User 665826-Dec-02 0:41 
GeneralRe: CArray woes Pin
Christian Graus26-Dec-02 0:47
protectorChristian Graus26-Dec-02 0:47 
GeneralRe: CArray woes Pin
User 665826-Dec-02 2:49
User 665826-Dec-02 2:49 
GeneralRe: CArray woes Pin
Christian Graus26-Dec-02 10:12
protectorChristian Graus26-Dec-02 10:12 
GeneralMMC tutorial required Pin
FASTian25-Dec-02 22:48
FASTian25-Dec-02 22:48 
Generalediting a menu Pin
citroen25-Dec-02 22:46
citroen25-Dec-02 22:46 
GeneralAdding WTL controls to MFC projects Pin
Hockey25-Dec-02 21:39
Hockey25-Dec-02 21:39 
QuestionLZH decompression? Pin
Dov Sherman25-Dec-02 20:00
Dov Sherman25-Dec-02 20:00 
AnswerRe: LZH decompression? Pin
Mike Nordell26-Dec-02 6:29
Mike Nordell26-Dec-02 6:29 
GeneralActiveX control Pin
chepuri_uk25-Dec-02 19:59
chepuri_uk25-Dec-02 19:59 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.