一个是实例 一个是指针 大小不一样感觉很正常。
不过确实2个的时候有问题
[view@localhost c]$cat ss.c
#include<stdio.h>
typedef struct man{
char name[10];
int age;
char phone[12];
}* pMAN;
int main(){
pMAN a=(pMAN)malloc(sizeof(pMAN)), b = (pMAN)malloc(sizeof(pMAN));
strcpy(a->name,"hwt");
a->age=34;
strcpy(a->phone,"18677151934");
strcpy(b->name,"hwt");
b->age=34;
strcpy(b->phone,"18677151934");
printf("a man named %s's age is %d,and phone is %s\n",a->name,a->age,a->phone);
printf("a man named %s's age is %d,and phone is %s\n",b->name,b->age,b->phone);
exit(0);
}
[view@localhost c]$cc -o ss ss.c
[view@localhost c]$./ss
a man named hwt's age is 34,and phone is hwt
a man named hwt's age is 34,and phone is 18677151934
不过确实2个的时候有问题
[view@localhost c]$cat ss.c
#include<stdio.h>
typedef struct man{
char name[10];
int age;
char phone[12];
}* pMAN;
int main(){
pMAN a=(pMAN)malloc(sizeof(pMAN)), b = (pMAN)malloc(sizeof(pMAN));
strcpy(a->name,"hwt");
a->age=34;
strcpy(a->phone,"18677151934");
strcpy(b->name,"hwt");
b->age=34;
strcpy(b->phone,"18677151934");
printf("a man named %s's age is %d,and phone is %s\n",a->name,a->age,a->phone);
printf("a man named %s's age is %d,and phone is %s\n",b->name,b->age,b->phone);
exit(0);
}
[view@localhost c]$cc -o ss ss.c
[view@localhost c]$./ss
a man named hwt's age is 34,and phone is hwt
a man named hwt's age is 34,and phone is 18677151934