struct char* 使用

 1 typedef struct people{
 2     char* name;
 3     int age;
 4 }PEO;
 5 
 6 void structdemo(){
 7    PEO* peo_0 = malloc(sizeof(PEO));
 8    peo_0->age = 20;
 9    peo_0->name = malloc(sizeof(char)*20);
10    peo_0->name = "jia";
11    free(peo_0); free(peo_0->name);
12 }

char* name or char name[20]

if not 

  peo_0->name = malloc(sizeof(char)*20);
fault
原文地址:https://www.cnblogs.com/zjhangia/p/10250820.html