#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2013
    Posts
    13
    Rep Power
    0

    Compiler output variation


    #include<stdio.h>
    int main()
    {
    float *p;
    printf("%d\n",sizeof(p));
    return 0;
    }

    why does this code gives an output 2 in 16 bit compiler like TCC/C++ and 4 in 32 bit compiler like Visual Studio or gcc??
    help
  2. #2
  3. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2013
    Location
    India
    Posts
    95
    Rep Power
    4
    because in 16 bit compiler address are of 2 bytes and in 32 bit address are of 4 bytes.
    pointer represent address only.
    so in 16 bit compiler it shows 2 and in 32 bit it shows 4.

    Comments on this post

    • salem agrees
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2013
    Posts
    13
    Rep Power
    0
    thank you.

IMN logo majestic logo threadwatch logo seochat tools logo