I keep the address of another variable in the dynamically allocated memory, and then print the dynamically allocated memory and the address of another variable. I understand that the address of base and p3 in group2 is the same, but why is buf in group1 different from p?
-sharpinclude <stdio.h>
int main(int argc, char const *argv[])
{
// group1
char buf[]="hello";
char *p=(char *)malloc(sizeof(char *));
*p=buf;
printf("buf=%p\n", buf);
printf("*p=%p\n", *p);
// group2
int base=1;
int *p3=(int *)malloc(sizeof(int *));
*p3=&base;
printf("base=%p\n", &base);
printf("*p3=%p\n", *p3);
return 0;
}