So I was trying to regrow this 1D dynamic array and I am unable to fix this error: Buffer overrun while writing to 'new_arr': the writable size is 'newLength*1' bytes, but 2 bytes might be written
void regrow(char *&arr, int &length,int newLength) //Funcion to regrow an array
{
char* new_arr = new char[newLength];
for (int index = 0; index < length; index++)
{
new_arr[index] = arr[index]; //**Error occurs here**
}
length = newLength;
delete[] arr;
arr = new_arr;
}
std::vectorclass does this work for you already. - PaulMcKenzielengthandnewLength? - BetanewLengthis smaller thanlength. - molbdnilo