#include <stdio.h>
typedef struct {
char a;
int b;
short c;
} MyStruct;
void print_offsets() {
MyStruct s;
char *base = (char*)&s;
size_t offset_a = (char*)&s.a - base;
size_t offset_b = (char*)&s.b - base;
size_t offset_c = (char*)&s.c - base;
printf("Offset of a: %zu\n", offset_a);
printf("Offset of b: %zu\n", offset_b);
printf("Offset of c: %zu\n", offset_c);
printf("Size: %zu", sizeof(MyStruct));
}
int main() {
print_offsets();
return 0;
}