结构体指针

参考http://www.cplusplus.com/doc/tutorial/structures/

#include <stdio.h>

struct People{
    int age;
    
};

int main(int argc, const char * argv[])
{

    struct People *p = malloc(sizeof(struct People));
    p->age = 10;

    struct People *p1 = p;
    p->age = 12;//p1的值也会改变,如果不是指针类型则不会有影响

    printf("age:%d\n", p1->age);

    free(p);//释放内存
    system("pause");
    return 0;
}

 

你可能感兴趣的:(结构体指针)