#include <stdio.h>
typedef struct {
char a;
int b;
short c;
} MyStruct;
void print_offsets() {
MyStruct obj;
//%z → modifier meaning “this matches a size_t”
//u → unsigned decimal integer
printf("Offset of a: %zu\n", (char*)&(obj.a)- (char*)&obj);
printf("Offset of b: %zu\n", (char*)&(obj.b) - (char*)&obj);
printf("Offset of c: %zu\n", (char*)&(obj.c) - (char*)&obj);
printf("Size: %zu\n", sizeof(MyStruct));
}
int main() {
print_offsets();
return 0;
}