S
singhraghvendra
See the program below. I am trying to copy 20 bytes of data in a 10
bytes of buffer. The copy succeeds and also it displays the result
correctly. But the delete [] a1 fails and gives an error. Can anyone
point out the exact reason why delete fails.
int main()
{
char*a1 = new char[10];
char* str20 = "12345678901234567890";
strcpy(a1,str20);
cout<<"a1: "<<a1;
delete [] a1;
}
bytes of buffer. The copy succeeds and also it displays the result
correctly. But the delete [] a1 fails and gives an error. Can anyone
point out the exact reason why delete fails.
int main()
{
char*a1 = new char[10];
char* str20 = "12345678901234567890";
strcpy(a1,str20);
cout<<"a1: "<<a1;
delete [] a1;
}