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 indirection in c?
how we can make 3d venturing graphics on outer interface
In which layer of the network datastructure format change is done
What is meant by 'bit masking'?
what is the c source code for the below output? 5555555555 4444 4444 333 333 22 22 1 1 22 22 333 333 4444 4444 5555555555
What is function pointer c?
How can you pass an array to a function by value?
Write a program to reverse a linked list in c.
When do you not use the keyword 'return' when defining a function a) Always b) Never c) When the function returns void d) dfd
What is difference between main and void main?
What are the different types of errors?
What is 02d in c?
How do you write a program which produces its own source code as output?
Explain how can you tell whether two strings are the same?
What is the right type to use for boolean values in c? Is there a standard type?