且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

未初始化和空指针之间的区别

更新时间:2023-01-05 21:44:44

获取未初始化的指针:

int* ptr;//points to any location in memory

采用空指针:

int* ptr = NULL;//normally points to 0x0 (0)

如果取消引用,两者都将导致未定义的行为. NULL通常定义为0.

Both would cause undefined behaviour if dereferenced. NULL is often defined as 0.