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

using only #include and #include Write a program in C that will read an input from the user and print it back to the user if it is a palindrome. The string ends when it encounters a whitespace. The input string is at most 30 characters. Assume the string has no spaces and distinguish between and lowercase. So madam is a palindrome, but MadAm is not a palindrome. Use scanf and %s to read the string. Sample Test: Enter a string: madam madam is a palindrome. Enter a string: 09023 09023 is not a palindrome.

1302


What is sizeof return in c?

607


An application package has been provided to you without any documents for the following application. The application needs to be tested. How will you proceed?

661


What is p in text message?

528


What does struct node * mean?

588






What is 2c dna?

596


What are structural members?

562


What is an operator?

650


How can you find out how much memory is available?

606


When I set a float variable to, say, 3.1, why is printf printing it as 3.0999999?

575


Explain what are preprocessor directives?

617


Find duplicates in a file containing 6 digit number (like uid) in O (n) time.

2586


Why isnt there a numbered, multi-level break statement to break out

581


What is the difference between procedural and declarative language?

638


Is it better to bitshift a value than to multiply by 2?

647