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 are the disadvantages of c language?
Differentiate between functions getch() and getche().
How can you avoid including a header more than once?
How does placing some code lines between the comment symbol help in debugging the code?
Given two strings S1 and S2. Delete from S2 all those characters which occur in S1 also and finally create a clean S2 with the relevant characters deleted.
Which is best linux os?
What is the difference between a string copy (strcpy) and a memory copy (memcpy)? When should each be used?
how could explain about job profile
How do we declare variables in c?
What are types of functions?
What is the difference between c &c++?
What is the use of typedef in c?
Why static variable is used in c?
What is meant by realloc()?
What does %d do in c?