CArchive
-
Hi, I have never used CArchive but a friend said it was easy to do. After a flustrating Sunday, I must defer to you. I have a CStringArray named: CStringArray m_sAstr; and I wish to store the total content into a binary carchive. Foo::LoadSave() { int nSize; // Create archive ... bool bReading = TRUE; // ... for writing CArchive* ar = NULL; CFile* pFile = new CFile(); ASSERT (pFile != NULL); if (!pFile->Open ("foo.txt", CFile::modeReadWrite | CFile::shareExclusive)){ return; } try { pFile->SeekToBegin(); UINT uMode = (bReading ? CArchive::load : CArchive::store); ar = new CArchive (pFile, uMode); ASSERT (ar != NULL); } catch (CException* pException) { return; } if(ar->IsStoring()) { nSize = m_sAstr.GetSize(); for(int i = 0;i<=nSize;i++){ ar->Write(m_sAsrt[i]); }else if(ar->IsLoading()) { } Please I am not sure what I am doing wrong. A small sample please. } "Naked we come and bruised we go." - James Douglas Morrison Best Wishes, ez_way
-
Hi, I have never used CArchive but a friend said it was easy to do. After a flustrating Sunday, I must defer to you. I have a CStringArray named: CStringArray m_sAstr; and I wish to store the total content into a binary carchive. Foo::LoadSave() { int nSize; // Create archive ... bool bReading = TRUE; // ... for writing CArchive* ar = NULL; CFile* pFile = new CFile(); ASSERT (pFile != NULL); if (!pFile->Open ("foo.txt", CFile::modeReadWrite | CFile::shareExclusive)){ return; } try { pFile->SeekToBegin(); UINT uMode = (bReading ? CArchive::load : CArchive::store); ar = new CArchive (pFile, uMode); ASSERT (ar != NULL); } catch (CException* pException) { return; } if(ar->IsStoring()) { nSize = m_sAstr.GetSize(); for(int i = 0;i<=nSize;i++){ ar->Write(m_sAsrt[i]); }else if(ar->IsLoading()) { } Please I am not sure what I am doing wrong. A small sample please. } "Naked we come and bruised we go." - James Douglas Morrison Best Wishes, ez_way
-
BaldwinMartin wrote: for(int i = 0;i<=nSize;i++){ you are doing an overflow guy ! prefer this :
for (int i = 0; i < nSize; i++) {
TOXCCT >>> GEII power
Hi And thnk you, I understand what you said is true, but my question was refering to CArchive. Is there an known issue in the storing of asym. data? Is there a problem with using a CList or CArray? I do thank you, and hope that you can help with these issues. "Naked we come and bruised we go." - James Douglas Morrison Best Wishes, ez_way