Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Watcom C Library Reference - <u>synopsis:</u> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
Synopsis:
    #include <stddef.h>
    size_t offsetof( composite, name );

Description:
    The offsetof macro returns the offset of the element name within the
     struct or  union composite.  This provides a portable method to
    determine the offset.

Returns:
    The offsetof function returns the offset of name.

Example:
    #include <stdio.h>
    #include <stddef.h>

    struct new_def
    {  char *first;
       char second[10];
       int third;
    };

    void main()
      {
        printf( "first:%d second:%d third:%d\n",
            offsetof( struct new_def, first ),
            offsetof( struct new_def, second ),
            offsetof( struct new_def, third ) );
      }

    produces the following:

    In a small data model, the following would result:

    first:0 second:2 third:12

    In a large data model, the following would result:

    first:0 second:4 third:14

Classification:
    ANSI

Systems:
    MACRO

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson