what is void pointer?

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


Please Help Members By Posting Answers For Below Questions

What is the use of typedef in c?

787


What is extern keyword in c?

872


What does a pointer variable always consist of?

872


What are register variables in c?

797


What is file in c preprocessor?

884


List out few of the applications that make use of Multilinked Structures?

1741


Write a program to print factorial of given number using recursion?

789


What language is windows 1.0 written?

777


what is bit rate & baud rate? plz give wave forms

1723


What is spark map function?

806


How do I determine whether a character is numeric, alphabetic, and so on?

862


What is the difference between exit() and _exit() function?

790


Linked list is a Linear or non linear explain if linear how it working as a non linear data structures

1956


Explain why C language is procedural?

980


What is the best way to comment out a section of code that contains comments?

1073