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. A Dynamic CString array cannot be deleted?

A Dynamic CString array cannot be deleted?

Scheduled Pinned Locked Moved C / C++ / MFC
data-structureshelptutorialquestion
6 Posts 4 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.
  • S Offline
    S Offline
    StarMeteor
    wrote on last edited by
    #1

    Hi everyone, I am trying to create an array dynamically with CString, here is an example: CString *a = new CString [nSize]; // nSize defined somewhere else // Some operation here ... delete a; but I catch an exception .... Would you mind suggest the problem here? Thanks a lot~

    S K C M 5 Replies Last reply
    0
    • S StarMeteor

      Hi everyone, I am trying to create an array dynamically with CString, here is an example: CString *a = new CString [nSize]; // nSize defined somewhere else // Some operation here ... delete a; but I catch an exception .... Would you mind suggest the problem here? Thanks a lot~

      S Offline
      S Offline
      StarMeteor
      wrote on last edited by
      #2

      oops ... I am foolish I should use CStringArray with SetSize() :(

      1 Reply Last reply
      0
      • S StarMeteor

        Hi everyone, I am trying to create an array dynamically with CString, here is an example: CString *a = new CString [nSize]; // nSize defined somewhere else // Some operation here ... delete a; but I catch an exception .... Would you mind suggest the problem here? Thanks a lot~

        K Offline
        K Offline
        kakan
        wrote on last edited by
        #3

        Did you try this? delete[] a;

        1 Reply Last reply
        0
        • S StarMeteor

          Hi everyone, I am trying to create an array dynamically with CString, here is an example: CString *a = new CString [nSize]; // nSize defined somewhere else // Some operation here ... delete a; but I catch an exception .... Would you mind suggest the problem here? Thanks a lot~

          C Offline
          C Offline
          Cool Ju
          wrote on last edited by
          #4

          Hi, Always follow the rule a = new => delete a a = new [] => delete a[] Bye, Cool Ju :cool: Dream Ur Destiny

          1 Reply Last reply
          0
          • S StarMeteor

            Hi everyone, I am trying to create an array dynamically with CString, here is an example: CString *a = new CString [nSize]; // nSize defined somewhere else // Some operation here ... delete a; but I catch an exception .... Would you mind suggest the problem here? Thanks a lot~

            M Offline
            M Offline
            Marc Soleda
            wrote on last edited by
            #5

            delete a[]; is the clue ... she said you are the perfect stranger she said baby let's keep it like this... Dire Straits

            1 Reply Last reply
            0
            • S StarMeteor

              Hi everyone, I am trying to create an array dynamically with CString, here is an example: CString *a = new CString [nSize]; // nSize defined somewhere else // Some operation here ... delete a; but I catch an exception .... Would you mind suggest the problem here? Thanks a lot~

              S Offline
              S Offline
              StarMeteor
              wrote on last edited by
              #6

              Really suddenly forget delete array should use delete [] =.= foolish me X| thanks everyone~

              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