struct class 内存结构初探-内存模型顺序和变量的实际添加顺序一致

typedef struct structTest {

    char xchar;

    int xint;

    int yint;

}xStruct;

@interface ViewController ()

{

    char xchar;

    int xint;

    int yint;

}

    xStruct xTest = {'a', 1, 2};

    NSLog(@"%p,%p, %p",&xTest.xchar, &xTest.xint, &xTest.yint);

    NSLog(@"%p,%p, %p", &xchar, &xint, &yint);

2017-02-22 14:39:01.957 structTest[53135:4290831] 0x7fff5f694a60,0x7fff5f694a64, 0x7fff5f694a68

2017-02-22 14:39:01.958 structTest[53135:4290831] 0x7fe5825115c0,0x7fe5825115c4, 0x7fe5825115c8

原文地址:https://www.cnblogs.com/feng9exe/p/6428872.html