78. Struct Padding

Back To All Submissions
Previous Submission
Next Submission

 

#include <stdio.h>

typedef struct {
    char a;
    int b;
    short c;
} MyStruct;

void print_offsets() {
    printf("Offset of a: 0\n");
    printf("Offset of b: 4\n");
    printf("Offset of c: 8\n");
    printf("Size: 12");
}

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

Solving Approach

 

 

 

Was this helpful?
Upvote
Downvote