#include <stdio.h>
int main(void) {
int a[5] = {1, 2, 3};
int len = sizeof(a) / sizeof(*a); // 数组 指针
int *b = &a[1]; // 数组
int *p = a; // 指针
printf("%d %d %d", len, *b, *p); // 5 2 1
return 0;
}
#include <stdio.h>
typedef struct tagStudent {
int cores[4];
int age;
} Student;
int main(void) {
Student *stu;
stu->cores[0] = 1;
printf("%d\n", sizeof(*stu)); //20
Student *stu2;
memcpy(stu2, stu, sizeof(Student));
printf("%d\n", stu2->cores[0]); // 1
stu->cores[0] = 3;
printf("%d\n", stu2->cores[0]); // 1
}
原文:https://www.cnblogs.com/kunlingou/p/12862447.html