很简单的结构体程序,麻烦看看这个程序错在哪
很久没有写c的程序了,拿个结构体来练练手 没想到编译虽然通过 但是执行报错:Segmentation fault[view@localhost c]$cat s.c
#include<stdio.h>
typedef struct man{
char *name;
int age;
char phone[12];
}* pMAN;
int main(){
pMAN a;
strcpy(a->name,"hwt");
a->age=34;
strcpy(a->phone,"18677151934");
printf("a man named %s's age is %s,and phone is %s\n",a->name,a->age,a->phone);
exit(0);
}
[view@localhost c]$cc -o s s.c
[view@localhost c]$./s
Segmentation fault