Deleting Allocated Memory

Hello,

I allocated an array of strings as follows.

char *pTokenList[] = {"Customer Purchase Order", "End User Purchase Order Number", "Delivery", "Carrier Name", "Actual Post Goods Issue date", "SumOfFreight Charges"};

At the end of the program, I tried to delete the allocated memory by doing the following.

delete[] pTokenList;

But it gives me run time failures (in debug mode). How do I properly delete the array or free the memory I allocated?

Thanks in advance,
Matt Simon

Only delete[] things allocated with new[]
Only delete things allocated with new
Only free() things allocated with malloc()/calloc()/etc


In your example, you did not use new to create pTokenList, therefore you must not try to delete it.




And... for what it's worth, you should not be manually using new/delete anyway. Use smart pointers and container classes so you do not have to worry about memory cleanup.
Topic archived. No new replies allowed.