how to delete this?

Discussion in 'C++' started by Kyle, Jul 26, 2004.

  1. Kyle

    Kyle Guest

    I have the following codes

    int (*p)[2];
    p=new int [4][2];
    ....
    delete [] p;

    is the way to free the memory correct?
    Kyle, Jul 26, 2004
    #1
    1. Advertising

  2. "Kyle" <> schrieb im Newsbeitrag
    news:...
    > I have the following codes
    >
    > int (*p)[2];
    > p=new int [4][2];
    > ...
    > delete [] p;
    >
    > is the way to free the memory correct?


    Yep. delete [] p; p=NULL; // indicate it's invalid!

    --
    -Gernot
    int main(int argc, char** argv) {printf
    ("%silto%c%cf%cgl%ssic%ccom%c", "ma", 58, 'g', 64, "ba", 46, 10);}

    ________________________________________
    Looking for a good game? Do it yourself!
    GLBasic - you can do
    www.GLBasic.com
    Gernot Frisch, Jul 26, 2004
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Sandeep Grover

    delete on delete !

    Sandeep Grover, Jul 12, 2003, in forum: C++
    Replies:
    19
    Views:
    609
    Chris \( Val \)
    Jul 22, 2003
  2. HeroOfSpielburg
    Replies:
    1
    Views:
    377
    Alf P. Steinbach
    Aug 6, 2003
  3. 0to60
    Replies:
    4
    Views:
    307
    Jerry Coffin
    Dec 19, 2003
  4. Mathieu Malaterre

    delete NULL, what about delete[] NULL

    Mathieu Malaterre, Aug 17, 2004, in forum: C++
    Replies:
    2
    Views:
    3,809
    Mathieu Malaterre
    Aug 17, 2004
  5. Jef Driesen
    Replies:
    1
    Views:
    492
    Gernot Frisch
    Jan 19, 2005
Loading...

Share This Page