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 are the disadvantages of c language?

623


Differentiate between functions getch() and getche().

625


How can you avoid including a header more than once?

567


How does placing some code lines between the comment symbol help in debugging the code?

549


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.

837






Which is best linux os?

566


What is the difference between a string copy (strcpy) and a memory copy (memcpy)? When should each be used?

626


how could explain about job profile

1456


How do we declare variables in c?

572


What are types of functions?

568


What is the difference between c &c++?

648


What is the use of typedef in c?

588


Why static variable is used in c?

559


What is meant by realloc()?

679


What does %d do in c?

547