Q:

void pointer in C

0

In this example, we will learn what is void pointer in C and how we can use void pointer in our C code.

For example, if you want to store the address of the character, the pointer should be a pointer to the character.

char cData;
 
char *pcData = NULL;
 
pcData = &cData;

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

#include <stdio.h>
int main(int argc, char *argv[])
{
    void *pvData = NULL; //void pointer
    int *iData  = NULL;// integer pointer
    char *cData = NULL;//character pointer
    float *fData = NULL;//float pointer
    //size of void pointer
    printf("size of void pointer = %d\n\n",sizeof(pvData));
    //size of void pointer
    printf("size of integer pointer = %d\n\n",sizeof(iData));
    //size of void pointer
    printf("size of character pointer = %d\n\n",sizeof(cData));
    //size of void pointer
    printf("size of float pointer = %d\n\n",sizeof(fData));
    return 0;

OutputOn a 32-bit machine

size of void pointer = 4
 
size of integer pointer = 4
 
size of character pointer = 4
 
size of float pointer = 4

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

C Program to calculate the size of the structure t... >>