例如 Cstduent *p1=new Cstduent;
Cstduent *p2 = p1;
delete p1;
p1=NULL;
此时p2指针指向一个无效内存区域,如何判断 指针指得内存区域有效呢?
我记得有个宏,忘了。
Cstduent *p2 = p1;
delete p1;
p1=NULL;
此时p2指针指向一个无效内存区域,如何判断 指针指得内存区域有效呢?
我记得有个宏,忘了。
调试欢乐多
Verifies that a specified memory range is valid for reading and writing (debug version only).int _CrtIsValidPointer( const void *address, unsigned int size, int access );
This function tests any memory address to ensure that it is contained entirely within the program’s memory space. The address is not restricted to blocks allocated by new.BOOL AfxIsValidAddress(
const void* lp,
UINT nBytes,
BOOL bReadWrite = TRUE );
如果 对于 发布版 可以使用 IsBadReadPtr 和 IsBadWritePtr 函数.
如果 对于 发布版 可以使用 IsBadReadPtr 和 IsBadWritePtr 函数.