Friday 22 March 2013

void *v;


    void main()
{
    void *v;
    int integer=2;
    int *i=&integer;
    v=i;
    printf("%d",(int*)*v);
}
Answer:
Compiler Error. We cannot apply indirection on type void*.
Explanation:
Void pointer is a generic pointer type. No pointer arithmetic can be done on it. Void pointers are normally used for,
1. Passing generic pointers to functions and returning such pointers.
2. As a intermediate pointer type.
3. Used when the exact pointer type will be known at a later point of time.

Blog Author: Vijay Kumar

No comments:

Post a Comment