What is a void pointer and what is a null pointer?

后端 未结 9 647
無奈伤痛
無奈伤痛 2020-11-29 00:32

So I was going through some interview questions and I came across one about void and null pointers, which claims:

a pointer with no return type is cal

9条回答
  •  佛祖请我去吃肉
    2020-11-29 00:52

    A void *ptr is the pointer which can be used to point any type of data. It maybe int, float, double. It has no return type that is initially pointer is created with pointer type (having hex value) and we can assign this pointer to any type of data.

    While null pointer is the pointer with having NULL value as address, the pointer is assigned NULL value so that it cannot be used to access others data which its address may contain while creation. I think it is good programming technique to assign a pointer NULL if its not used at the moment.

提交回复
热议问题