I'm not understanding something simple.
I have this sample code:
typedef struct {
  char* fname;
} PersonType;
int main() {
  PersonType *p;
  p  = (PersonType *)malloc(sizeof(PersonType));
  char * name = "Robert";
  /* this next line causes a segmentation fault */  
  strcpy(p->fname, name);
  printf("name: %s\n", p->fname);
}
Why is there a segmentation fault at the 'strcpy'? What am I doing wrong?
Any help is greatly appreciate, thanks!
Rob
 
     
    