Try this.
#include <stdio.h>
#include <stdlib.h>
#include <stddef.h>
typedef struct { int a, b, c; } s_tr;
int main(int argc, char **argv){
size_t distance;
distance = offsetof(s_tr, c);
printf("Offset of x.c is %lu bytes\n",
(unsigned long)distance);
exit(EXIT_SUCCESS);
}
Also, this question and answer from the C-FAQ might help your understanding:
Q: What's the difference between these two declarations?
struct x1 { ... };
typedef struct { ... } x2;
A: The first form declares a structure tag; the second declares a typedef. The main difference is that the second declaration is of a slightly more abstract type--its users don't necessarily know that it is a structure, and the keyword struct is not used when declaring instances of it:
x2 b;
Structures declared with tags, on the other hand, must be defined with the
struct x1 a;
form. [footnote]
(It's also possible to play it both ways:
typedef struct x3 { ... } x3;
It's legal, if potentially obscure, to use the same name for both the tag and the typedef, since they live in separate namespaces. See question 1.29.)