1.typedef定义一个结构体,Person变量和*pPerson指针变量。特别注意在实参传址的时候,已经typedef指针变量的时候,形参就写pPerson p,不用取*号;而形参Person *p就要取*号,在我看来person不是指针变量就要写
#include <stdio.h>typedef struct
{int num;char name[32];char sex;
}Person,*pPerson;void printInfo(Person p)
{printf("%d号姐姐:%s %c \n",p.num,p.name,p.sex);
}void printInfo1(pPerson pp)
{printf("%d号姐姐:%s %c \n",pp->num,pp->name,pp->sex);
}void printInfo2(Person *p)
{printf("%d号姐姐:%s %c \n",p->num,p->name,p->sex);
}int main()
{Person p1 = {1,"美美",'g'};Person p2 = {2,"丽丽",'g'};printInfo(p1);printInfo(p2);pPerson pp1 = &p1;pPerson pp2 = &p2;printInfo1(pp1);printInfo1(pp2);Person *pp3 = &p1;Person *pp4 = &p2;printInfo2(pp3);printInfo2(pp4);return 0;
}