Hello All,
I am creating the array of size: 26627664 bytes then convert the byte to char array.
While deleting the array i got an code gaurd log error that Bad Parameter.

I am doing like this
Char* pBuffer = (Char*)new BYTE[26627664];

and deleting like this,
if(pBuffer != NULL)
delete[] pBuffer;
facing the problem
Please Help.

Recommended Answers

All 2 Replies

Add this line of code in and see if the array will delete:

pBuffer[26627664] = '\0';

>pBuffer[26627664] = '\0';
You've got an off-by-one error. Do try to remember that array indexing in C is based on an offset, not an item count. pBuffer[0] is the first item, so pBuffer[N-1] is the last item, and pBuffer[N] is an overflow error.

>Char* pBuffer = (Char*)new BYTE[26627664];
How are BYTE and Char defined?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.