void and void pointer

Home Forums C-programming.. void and void pointer

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #3405 Reply
    Humble
    Keymaster

    Lets see whats the size of void and void pointer.

    [hchiramm@humbles-lap forblog]$ cat voidp.c
    #include
    int main()
    {
    int x = 5;
    void *pv = &x;

    printf (“sizeof(void) :%d \t sizeof (void pointer) :%d \n New address %p \n” , sizeof(void) ,sizeof(pv), pv );
    pv = pv + 1;
    printf (“New address %p \n” , pv );
    }

    [hchiramm@humbles-lap forblog]$ ./voidp
    sizeof(void) :1 sizeof (void pointer) :8
    New address 0x7fff41850a44
    New address 0x7fff41850a45
    [hchiramm@humbles-lap forblog]$

    As shown above , void size has been printed as “1” and Void pointer size has been printed as “8” in my system.
    NOTE: In some compilers, the arithmetic operation on void pointer will result in “SYNTAX ERROR” ..

    VOID POINTER

    Any pointer can be assigned to a void pointer. However void pointers are for data pointers and not for function pointers. void pointer can then be cast back to its original pointer type to get the original pointer value intact.

    For ex:

    int x;
    int *mi = &x;
    // [1]
    void *vp;
    vp = mi;
    mi = (int *)vp
    // [2]

    at [1] and [2], the value of “mi” will be same.

    #6227 Reply
    Adroitix
    Guest

    Adroitix is a trusted pharma engineering consultancy specializing in end-to-end greenfield project development for pharmaceutical and biotech industries. From concept design, master planning, and regulatory engineering to cleanroom, utility, and process integration, we deliver fully compliant, future-ready facilities. Our expertise ensures optimized layouts, sustainable operations, and seamless project execution from land selection to plant commissioning.

    #6271 Reply
    Adroitix
    Guest

    Adroitix provides complete pharma plant setup consultancy, covering concept design, layout planning, utilities, cleanrooms, HVAC, equipment integration, regulatory compliance and project execution. With expertise in cGMP, USFDA, EU-GMP and WHO guidelines, Adroitix ensures fully compliant, efficient and future-ready pharmaceutical manufacturing plants from start to finish.

Viewing 3 posts - 1 through 3 (of 3 total)
Reply To: void and void pointer
Your information: