Answer Posted / 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 View All Answers
What is a ternary operator in c?
What is the use of linkage in c language?
What does a pointer variable always consist of?
Here is a good puzzle: how do you write a program which produces its own source code as output?
Difference between linking and loading?
How can I determine whether a machines byte order is big-endian or little-endian?
What is data structure in c programming?
Why c language?
Are local variables initialized to zero by default in c?
Read the following data in two different files File A: aaaaaaaadddddddd bbbbbbbbeeeeeeee ccccccccffffffff File B: 11111111 22222222 33333333 By using the above files print the following output or write it in the Other file as follows aaaaaaaa11111111dddddddd bbbbbbbb22222222eeeeeeee cccccccc33333333ffffffffffff
What is the difference between typedef and #define?
Can you please explain the difference between exit() and _exit() function?
What does printf does?
What is the difference between procedural and functional programming?
where are auto variables stored? What are the characteristics of an auto variable?