NVIDIA Interview Question

how do you implement a sizeof operator without using the sizeof operator

Interview Answers

Anonymous

Jan 14, 2013

#define my_sizeof(t) (((t *) 0) + 1)

2

Anonymous

Nov 10, 2012

To find the size of a of type tStruct; tStruct *pstruct1 = &structobj; tStruct * pstruct2 = ++pstruct1 ; int size = (char*)pstruct2 - (char*)pstruct1;

1