mardi 26 juillet 2016

issue in double pointer address addition

I have got one issue from a open source code in pointers side, which i have tried to replicate in this below small snippet.

int main()
{
int **a=0x0;
printf ("a = %d Add = %dn", a, a+75);
return 1;
}

Expectation is to get 75/0x4B but this code gives 300 in 32 bit and 600 in 64 bit machines.

Output:

a = 0 Add = 600

But the ideology behind to access the added position i.e 75th position in Hash table.

So it should be

printf ("a = %d Add = %dn", a, sizeof (a)+75);

But i couldn't able to guess why this 300 or 600 output. could anyone please point out?

I went till a point where there is some left shift internally happening since:

75 - 1001011
600 - 1001011000.

Solutions are appreciated. Thanks in advance.

Aucun commentaire:

Enregistrer un commentaire