This topic is now archived and is closed to further replies.

what's the diff between delete and delete[]?

This topic is 5826 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

char *Dib = new char[Size*8]; i allocate memory using the above code. from what i know, i would simply call delete [] DibA to delete DibA. but this is what i do with it:
if (GetDib(&Size, (long*)(Dib+Size*i)))
	m_Frames = (Dib+Size*i);				
this code is in a for-loop with i going from 0 to 8, [0,8). and m_Frames is a long m_Frames[8]. so each loop i fill part of the array and i make m_Frames point to the "current index". how do i delete this? delete [] m_Frames[0], delete [] m_Frames, or delete m_Frames[0]. i think it should be delete [] m_Frames[0] but i''m not sure.

Share this post

Link to post
Share on other sites
Guest Anonymous Poster
Its been a while since ive done pointers but here goes..... delete is just to delete one pointer, delete[] will either delete all the pointers in an array of just te ones specified,
i.e. delete[1,3,5] MyArrray[10]

once again, im not exactly sure but try out methods and you will find the answers you seek

Share this post

Link to post
Share on other sites