#include<stdio.h>
#include<stdlib.h>
#include<malloc.h>
typedef struct TNode{
int data;
struct TNode * next;
}TNode,*Tree;
int main(){
Tree a,b,c,d;
c=(Tree)malloc(sizeof(TNode));
c->data=7;c->next=NULL;
d=(Tree)malloc(sizeof(TNode));
d->data=10;d->next=NULL;
a=b=(Tree)malloc(sizeof(TNode));//这儿是关键
//-------------1------------------
b=c;
printf("b=c\n");
printf("b->data= %d \n",b->data);
printf("a->data= %d \n",a->data);
//------------2-----------------
// b->next=c;
// printf("b->next=c\n");
// printf("b->data=%d\n",b->data);
// printf("a->data=%d\n",a->data);
// printf("b->next->data= %d \n",b->next->data);
// printf("a->next->data= %d \n",a->next->data);
//
// a->next=d;
// printf("a->next&
C语言结构体中指针的复制问题
最新推荐文章于 2022-06-17 13:55:11 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)