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
Explain about C function prototype?
Explain how do you list a file’s date and time?
Some coders debug their programs by placing comment symbols on some codes instead of deleting it. How does this aid in debugging?
What is the benefit of using #define to declare a constant?
all c language question
What is c system32 taskhostw exe?
Are local variables initialized to zero by default in c?
write a program to print data of 5 five students with structures?
What is the difference between c &c++?
Explain what does the characters 'r' and 'w' mean when writing programs that will make use of files?
Is multithreading possible in c?
a program that performs some preliminary processing in C, it acts upon certain directives that will affect how the compiler does its work a) compiler b) loader c) directive d) preprocessor
What is class and object in c?
Once I have used freopen, how can I get the original stdout (or stdin) back?
write a program to find the given number is prime or not