+ Reply to Thread
Results 1 to 2 of 2

Thread: What is difference between delete[] and delete?

  1. #1
    Junior Member
    Join Date
    Feb 2012
    Posts
    48

    What is difference between delete[] and delete?

    What is difference between delete[] and delete?

    Is below code safe:

    Code:
    char *p = new char[100] ;
    delete p ; //note that I am not using [] before delete

  2. #2
    Senior Member
    Join Date
    Feb 2012
    Posts
    109
    No, it is not safe.

    Always use the delete [] whenever you created pointer with new[].

    If you do not use correct delete then behavior is undefined.

+ Reply to Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts