码迷,mamicode.com
首页 > 其他好文 > 详细

结构体指针

时间:2016-03-16 00:57:02      阅读:131      评论:0      收藏:0      [点我收藏+]

标签:

参考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;
}

 

结构体指针

标签:

原文地址:http://www.cnblogs.com/haciont/p/5281810.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!