heapchec.c
来自「vc library 韩国语版 希望对大家又帮助」· C语言 代码 · 共 34 行
C
34 行
#include <stdio.h>
#include <alloc.h>
void main()
{
char *array[10];
int i;
int result;
for( i = 0; i < 10; i++ )
array[ i ] = (char *) malloc( 20 );
for( i = 0; i < 10; i += 2 )
free( array[ i ] );
result=heapcheck();
if( result == _HEAPCORRUPT )
printf("Heap is corrupted.\n");
else if ( result == _HEAPEMPTY)
printf("Heap is empty.\n");
else
printf("Heap is OK.\n" );
*(array[5]-1)=0xff;
printf("after corrupt : ");
result=heapcheck();
if( result == _HEAPCORRUPT )
printf("Heap is corrupted.\n");
else if ( result == _HEAPEMPTY)
printf("Heap is empty.\n");
else
printf("Heap is OK.\n" );
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?