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 |
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....
Hai what is the different types of versions and their differences
What is the meaning of this decleration? unsigned char (*pArray[10][10]); please reply.
Tell me with an example the self-referential structure?
how to go with this?
where do we use volatile keyword?
What is c language in simple words?
What is the difference between File pointer and Internal Charecter Pointer?
A global variable when referred to in another file is declared as this a) local variable b) external variable c) constant d) pointers
whether itis a structured language?
i have a written test in tomorrow
What is auto keyword in c?