一、NULL
C++和C中NULL的定义:
#ifndef NULL
#ifdef __cplusplus
#define NULL 0
#else
#define NULL ((void *)0)
#endif
#endif
示例代码:
#include <stdio.h>
int main()
{
int *p = NULL;
printf("%s", p);
int a = 1;
printf("a=%d\n",a);
return 0;
}
断点调试:
输出<null> ,单步调试可以看出执行int *p=NULL,p的值为0x00000000,可以看出,NULL在实际底层调用中就是0。
参考链接: