1. A heap corruption detected error occurred in the memory of the free application.
Heap corruption. When the input exceeds the amount of pre-allocated space, it overwrites a storage area after that space, which is called the heap corruption. This is often also used as a means of hacking, because if the storage area after the space is more important data, you can use the heap corruption to modify the data, of course, the consequences are conceivable.
Char " Hello " ; int Array_length = strlen (a); char* p = NULL; = (char*) malloc (sizeof(char) *array_length); strcpy (P, a); Free (p);
The following is normal and this error does not occur.
Char " Hello " ; // ' 0 ' int Array_length = strlen (a) +1; char* p = NULL; = (char*) malloc (sizeof(char) *array_length); strcpy (P, a); Free (p); = NULL;
When declaring a character array, the number in [] should be the number of characters in the array, including '/0 '
such as char p[5] = "dddd";
The actual is: ' d ' d ' d ' d '/0 '.
If char p[5] = "DDDDD";
Compile error, prompting out of bounds.
C + + Memory error pooling