GeekInterview.com
Series: Subject: Topic:
Question: 770 of 827

What is a void pointer?

A void pointer is a C convention for “a raw address.” The compiler has no idea what type of object a void Pointer “really points to.” If you write int *ip; ip points to an int. If you write void *p; p doesn’t point to a void! In C and C++, any time you need a void pointer, you can use another pointer type. For example, if you have a char*, you can pass it to a function that expects a void*. You don’t even need to cast it. In C (but not in C++), you can use a void* any time you need any kind of pointer, without casting. (In C++, you need to cast it).  A void pointer is used for working with raw memory or for passing a pointer to an unspecified type. Some C code operates on raw memory. When C was first invented, character pointers (char *) were used for that. Then people started getting confused about when a character pointer was a string, when it was a character array, and when it was raw memory.  
Asked by: Interview Candidate | Asked on: Mar 6th, 2005
Showing Answers 1 - 2 of 2 Answers
Ashwan

Answered On : Jul 26th, 2007

Void Pointer or Generic Pointer is the one to which any datatype can be assigned.eg.main(){    int *p;     void *vp;     vp=p;}

  
Login to rate this answer.
ashish

Answered On : Aug 18th, 2011

The pointer is easily convert into any other type of pointer variable is called void pointer.

Main ex-dynamic memory allocation function use void pointer to convert to type of pointer.

  
Login to rate this answer.

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

Related Open Questions

Ads

Connect

twitter fb Linkedin GPlus RSS

Ads

Interview Question

 Ask Interview Question?

 

Latest Questions

Interview & Career Tips

Get invaluable Interview and Career Tips delivered directly to your inbox. Get your news alert set up today, Once you confirm your Email subscription, you will be able to download Job Inteview Questions Ebook . Please contact me if you there is any issue with the download.