typedef struct{ int a; int b; }M; int main(int argc, char *argv[]) { M c; printf("%d\n",&c); M b; printf("%d\n",&b);//b的地址 b = c;//b的值等于c printf("%d\n",&b);//b的地址未变 M* ca = (M*)malloc(sizeof(M)); ca->a = 3; M* ce = (M*)malloc(sizeof(M)); printf("%d %d ca ce\n",&ca,&ce); ce = ca;//ce的 值(指针地址) 等于ca printf("%d %d \n",&ce,ce->a);//ce的地址未变 3 return 0; }
时间: 2024-11-15 20:21:48