```
struct s11
{
    alignas(16) char s;
    int i;
};

```

1. does `alignas(n) X x` mean it would allocate n bytes to hold a `X`, when `X` is actually much smaller than n bytes, the rest memory would be all 0s?
2. when `s11.s` is in memory `0x0`, does that mean `s11.i` would be at `0x10`? However, the following `pdiff` is `0x4`

```
s11 o;
ptrdiff_t pdiff = (char*)&o.i - (char*)&o.s;

```

3. Please explain why `sizeof(s11)` is not 16 times 2, while `sizeof(s1)` is 8 times 3?

```
struct s1
{
    char s;
    double d; // alignof(double) is 8. 
    int i;
}

```

EDIT:
This is what I found after a lot of digging and code snippets, that how alignas affect struct(class) size.

`alignas(n) X x` means in memory `x` is located at a place with an offset of multiple of `n` bytes, starts from 0x00. Therefore, `s11.s` can be located at 0x00, 0x10, 0x20 and so on. Because `s11.s` is the first field, it is at 0x00, and it is a char, so it ocupies 1 bytes.

So is the 2nd field. `int` has an align 4, therefore it can be located at 0x00, 0x04, 0x08, 0x0c, etc. Because the first byte is taken by `s11.s`, so `s11.i` is located at 0x04.