What is difference between void pointer and null pointer?

A pointer which can point any type of data is known as void pointer or generic pointer. For example:
void main(){
    int i=10;
    float f=10.5f;
    void *ptr;  //void pointer
    printf("%d",*(int *)ptr);
    printf("%d",*(float *)ptr);
In this example ptr is void pointer which can points int type data or float type data.
While null pointer is any type of pointer is pointing to nothing i.e. which is pointing to a null value. 

No comments: