All submissions

Code

#include <stdio.h>
#include <stdint.h>
typedef struct {
    char a;
    int b;
    short c;
} MyStruct;

void print_offsets() {

    MyStruct ms;

    printf("Offset of a: %u\n",(uint64_t)&ms-(uint64_t)&ms.a);
    printf("Offset of b: %u\n",(uint64_t)&ms.b-(uint64_t)&ms);
    printf("Offset of c: %u\n",(uint64_t)&ms.c-(uint64_t)&ms);
    printf("Size: %u",sizeof(ms));
 
}

int main() {
    print_offsets();
    return 0;
}

Solving Approach

 

 

 

Loading...

Input

Expected Output

Offset of a: 0 Offset of b: 4 Offset of c: 8 Size: 12