P*******b 发帖数: 1001 | 1 You are given have a datatype, say X in C.
The requirement is to get the size of the datatype, without declaring a vari
able or a pointer variable of that type,And, of course without using sizeof
operator ! |
t*q 发帖数: 104 | 2 (int)((X*)0 + 1)
vari
sizeof
【在 P*******b 的大作中提到】 : You are given have a datatype, say X in C. : The requirement is to get the size of the datatype, without declaring a vari : able or a pointer variable of that type,And, of course without using sizeof : operator !
|
s*********t 发帖数: 1663 | 3 why do you want to do this?
vari
sizeof
【在 P*******b 的大作中提到】 : You are given have a datatype, say X in C. : The requirement is to get the size of the datatype, without declaring a vari : able or a pointer variable of that type,And, of course without using sizeof : operator !
|
P*******b 发帖数: 1001 | 4 面试题,没办法
【在 s*********t 的大作中提到】 : why do you want to do this? : : vari : sizeof
|
P*******b 发帖数: 1001 | 5 这个是pointer arithemtic吧,好像不让。
【在 t*q 的大作中提到】 : (int)((X*)0 + 1) : : vari : sizeof
|
r*********s 发帖数: 2157 | 6 #define sizeof_type( X ) \\
(size_t)((X*)1000 + 1 ) - (size_t)((X*)1000) |
t*q 发帖数: 104 | 7 题目里没说啊,如果不让用,我觉得无解
【在 P*******b 的大作中提到】 : 这个是pointer arithemtic吧,好像不让。
|