首页 > 其他 > 详细

结构体指针

时间:2016-03-16 00:55:36      阅读:157      评论: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
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!