Adobe Interview Question
Software Engineer / DevelopersGarbage value should be displayed.
for tmp+=1, 20 will be displayed.
so for tmp+=4,garbage value is displayed.
I am just rephrasing zhen's word
since we are doing tmp+=sizeof(int);
hence if size of int is 2 bytes on a machine then temp will point to value 30 (2 index ahead from oth index) of array and we will get 30 after that it will print garbage as it will be pointing out of array boundaries...
Shouldn't.
- Zhen January 22, 2011tmp is int* so tmp+1 moves the pointer 4 bytes forward. tmp+=sizeof(int) == tmp+=4 this pushes tmp 16 bytes forwards so nothing meaningful but shit is outputing.