Qualcomm Interview Question: Unexpected question was the l... | Glassdoor

Interview Question

Embedded Software Engineer Interview Boulder, CO

Unexpected question was the last one where he asked how to

  find sizeof(data type) without using sizeof() function. I googled later on how to do this and found out it was something to do with with null pointers and I would not have thought of that at the time.
Answer

Interview Answer

1 Answer

0

just subtract the difference between consequent address positions, after casting it into an 8bit variable pointer.
uint64_t a = 9;
uint8_t num_bytes = (uint8_t*)(&a+1) - (uint8_t*)(&a);

Anonymous on Jun 12, 2016

Add Answers or Comments

To comment on this, Sign In or Sign Up.