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

深拷贝和浅拷贝

时间:2017-09-14 23:46:15      阅读:198      评论:0      收藏:0      [点我收藏+]

标签:深拷贝   浅拷贝   

#include <stdio.h>

int main(int argc, char *argv[])
{
    char *p1="123";
    char *p2="123";
    char *p3="456";
    const char *p4="abc";
    const char *p5="abc";
    const char *p6="def";
    printf("p1地址:%x\n",p1);
    printf("p2地址:%x\n",p2);
    printf("p3地址:%x\n",p3);
    printf("p4地址:%x\n",p4);
    printf("p5地址:%x\n",p5);
    printf("p6地址:%x\n",p6);
    char *a="windows";
    char *b="123";
    printf("a地址:%x\n",a);
    printf("b地址:%x\n",b);
    b=a;
    printf("b=a后:\n");
    printf("a地址:%x\n",a);
    printf("b地址:%x\n",b);
    printf("a的内容:");
    puts(a);
    printf("b的内容:");
    puts(b);

    char str[80]="win10";
    char *p=str;
    printf("str地址:%x\n",str);
    printf("p地址:%x\n",p);
    printf("str的内容:");
    puts(str);
    printf("p的内容:");
    puts(p);
    str[3]=‘x‘;
    printf("str[3]=‘x‘后:\n");
    printf("str地址:%x\n",str);
    printf("p地址:%x\n",p);
    printf("str的内容:");
    puts(str);
    printf("p的内容:");
    puts(p);
    return 0;
}

技术分享

本文出自 “10628473” 博客,请务必保留此出处http://10638473.blog.51cto.com/10628473/1965425

深拷贝和浅拷贝

标签:深拷贝   浅拷贝   

原文地址:http://10638473.blog.51cto.com/10628473/1965425

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