Welcome Guest | Sign in | Register
Pointers - Discussion Page For Q.10750 | C Programming Questions and Answers | C Programming Free Online-Tests | LucentBlackBoard | LucentBlackBoard.com

Home > Java Programming > Pointers > Questions and Answers

Q: Predict the output or error(s) for the following?

void main()
{
void *v;
int integer=2;
int *i=&integer;
v=i;
printf("%d",(int*)*v);
}
A. No output B. 2
C. Compiler error D. None of these

Answer and Explanation

Answer:Compiler error

Explanation:
We cannot apply indirection on type void*.

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.

Comment on this Question

Name:

Loading...




Partner Sites
LucentBlackBoard.com                  SoftLucent.com                  LucentJobs.com
All rights reserved © 2012-2015 SoftLucent.