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 the use of typedef in c?
What is extern keyword in c?
What does a pointer variable always consist of?
What are register variables in c?
What is file in c preprocessor?
List out few of the applications that make use of Multilinked Structures?
Write a program to print factorial of given number using recursion?
What language is windows 1.0 written?
what is bit rate & baud rate? plz give wave forms
What is spark map function?
How do I determine whether a character is numeric, alphabetic, and so on?
What is the difference between exit() and _exit() function?
Linked list is a Linear or non linear explain if linear how it working as a non linear data structures
Explain why C language is procedural?
What is the best way to comment out a section of code that contains comments?