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

I use turbo C which allocates 2 bytes for integers and 4 bytes for long. I tried to declare array of size 500000 of long type using the following code... long *arr; arr=(long *)(malloc)(500000 * sizeof(long)); It gives a warning that "Conversion may lose significant digits in function main"... And the resulting array size was very less around 8400 as compared to 500000. Any suggestions will be welcomed....

2 Answers  


Hai what is the different types of versions and their differences

0 Answers  


What is the meaning of this decleration? unsigned char (*pArray[10][10]); please reply.

1 Answers  


Tell me with an example the self-referential structure?

0 Answers  


how to go with this?

1 Answers   Wipro,


where do we use volatile keyword?

1 Answers  


What is c language in simple words?

0 Answers  


What is the difference between File pointer and Internal Charecter Pointer?

2 Answers   TATA,


A global variable when referred to in another file is declared as this a) local variable b) external variable c) constant d) pointers

0 Answers  


whether itis a structured language?

1 Answers   Microsoft,


i have a written test in tomorrow

1 Answers   NNN, Value Labs,


What is auto keyword in c?

0 Answers  


Categories