IT Placement Papers Programming C
This category contains C Interview Questions and Answers |
How can I determine the byte offset of a field within a structure?
|
|
|
|
|
ANSI C defines the offsetof() macro, which should be used if
available; If you don't have it, one possible
implementation is
#define offsetof(type, mem) ((size_t) \
((char *)&((type *)0)->mem - (char *)(type *)0))
This implementation is not 100% portable; some compilers may
legitimately refuse to accept it.
Only registered users can write comments. Please login or register.
|