C: Why do unassigned pointers point to unpredictable memory and NOT point to NULL?

后端 未结 11 1431
没有蜡笔的小新
没有蜡笔的小新 2020-12-05 04:25

A long time ago I used to program in C for school. I remember something that I really hated about C: unassigned pointers do not point to NULL.

I asked many people in

11条回答
  •  遥遥无期
    2020-12-05 04:48

    For it to point to NULL it would have to have NULL assigned to it ( even if it was done automatically and transparently ).

    So, to answer your question, the reason a pointer can't be both unassigned and NULL is because a pointer can not be both not assigned and assigned at the same time.

提交回复
热议问题