Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. CArchive

CArchive

Scheduled Pinned Locked Moved C / C++ / MFC
question
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    BaldwinMartin
    wrote on last edited by
    #1

    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

    T 1 Reply Last reply
    0
    • B BaldwinMartin

      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

      T Offline
      T Offline
      toxcct
      wrote on last edited by
      #2

      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

      B 1 Reply Last reply
      0
      • T toxcct

        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

        B Offline
        B Offline
        BaldwinMartin
        wrote on last edited by
        #3

        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

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups