how to free the memory?

Discussion in 'Programmer's Corner' started by summeranson, Sep 24, 2009.

  1. summeranson

    Thread Starter Member

    Feb 12, 2009
    28
    0
    What should you do to free the memory after running this code?

    char *a; a = new char[20];


    A. I don't know


    B. delete [] a;

    C. delete a[];

    D. delete a;
     
  2. nanovate

    Distinguished Member

    May 7, 2007
    665
    1
    Shouldn't this be in the homework section?
     
  3. Mark44

    Well-Known Member

    Nov 26, 2007
    626
    1
    Are you using a textbook? If so, look at the section on the various forms of delete that are associated with new.
     
  4. dushuai

    New Member

    Sep 9, 2009
    10
    0
    delete is associated with new,and a is an point array,so you should use delete a to delete the point array
     
Loading...