#include
#include
main()
{
struct stu
{
char name[20];
}*p;
p=(struct stu )malloc(sizeof(struct stu));
scanf("%s",p->name);
printf("name:%s\n",&(p->name));
printf("name:%s\n",*&(p->name));
printf("name:%s \n",&(p->name));
}
这三者作用相同,意思有什么不同么
都能编译运行,都能输出,q区别什么
p->name是数组,相当于指针
而对于%s,无论是数组地址还是数组首元素地址,其实一样,所以3的结果也一样
p是指针,指向数组首元素,p->name是一个char,就是名字,最终打印的1.3都是&后的地址,2是char组