Skip to content

Instantly share code, notes, and snippets.

@IS-BrianLian
Created June 16, 2016 14:30
Show Gist options
  • Save IS-BrianLian/cff04a8d7b17c1d752e86bec25e0a7cf to your computer and use it in GitHub Desktop.
Save IS-BrianLian/cff04a8d7b17c1d752e86bec25e0a7cf to your computer and use it in GitHub Desktop.

Revisions

  1. IS-BrianLian created this gist Jun 16, 2016.
    20 changes: 20 additions & 0 deletions struct_alignment.c
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,20 @@
    #include <stdio.h>
    #include <stdlib.h>

    struct test {
    char a;
    int b;
    char c;
    long d;
    };

    int main() {
    struct test s;

    printf("char a address is %p\n", &s.a);
    printf("int b address is %p\n", &s.b);
    printf("char c address is %p\n", &s.c);
    printf("long d address is %p\n", &s.d);

    return 0;
    }