#include <stdio.h>
#include <stdint.h>
typedef struct {
char a;
int b;
short c;
} MyStruct;
void print_offsets() {
MyStruct s;
// Coerc types of pointers to uint8_t to make operate adresses like numbers
uint8_t *ps = (uint8_t *)&s;
uint8_t *pa = (uint8_t *)&s.a;
uint8_t *pb = (uint8_t *)&s.b;
uint8_t *pc = (uint8_t *)&s.c;
printf("Offset of a: %d\n", pa - ps);
printf("Offset of b: %d\n", pb - ps);
printf("Offset of c: %d\n", pc - ps);
printf("Size: %d\n", sizeof(s));
}
int main() {
print_offsets();
return 0;
}