what is void pointer?



what is void pointer?..

Answer / himaja

pointers can also be declared as void type.void pointers cant be dereferenced without explict type conversion,this is becoz being void the compiler cnt determine the size of object that pointer points to,though void vaariables declared is not allowed,thus void p displays error msg "size of p is unknown or 0" after compilation
#include<stdio.h>
int p;
float d;
char c;
void *pt=&p;
void main(void)
{
clrscr();
*(int*)pt=12;
printf("\n p=%d",p);
pt=&d; /*pt points to d*/
*(float*)pt=5.4;
printf("\n r=%f",d);
pt=&c; /*pt points to c*/
*(char*)pt=H;
printf("\n c=%c",c);


o/p:
P=12
R=5.4
C=H

Is This Answer Correct ?    6 Yes 0 No

Post New Answer

More C Interview Questions

write a function for strtok()??

2 Answers   Verifone,


what is the code for getting the output as * ** ***

5 Answers   Caritor,


Efficient data structure for store/search list of 1000 records a)array b)double linked list c)circular queue d)hash table

3 Answers   Value Labs,


how to write a cprogram yo get output in the form * *** ***** ******* ********* ******* ***** *** *

3 Answers  


What is the difference between far and near in c?

0 Answers  






what are advantages of U D F?

1 Answers   Google,


How to find the given no is odd or even without checking of any condition and loops. (Hint: Using array)

4 Answers  


find the value of y y = 1.5x+3 for x<=2 y = 2x+5 for x>2

0 Answers   TCS,


how can i get output the following... 5 4 3 2 1 4 3 2 1 3 2 1 2 1 1 and 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 plz plz...

3 Answers  


how can i print "hello"

3 Answers  


Can we initialize extern variable in c?

0 Answers  


How to reverse a linked list

1 Answers   Aricent, Fidelity, IBM, TCS,


Categories