我正在学习C语言。任何人都可以帮助我理解以下结果:
int main()
{
  struct xx
  {
    int x;
    char name[];
  };
  struct xx *s;
  printf("%d",s->x);
  printf("%s",s->name);
   return 0;
}
输出:- 分段错误
我写了另一个代码是:
struct Foo
{
  char *pName;
};
int main()
{
  struct Foo *obj = malloc(sizeof(struct Foo));
  strcpy(obj->pName,"Your Name");
  printf("%s", obj->pName);
  return 0;
} 
输出:分段错误(核心转储);
为什么我会遇到分段错误?代码有什么问题?核心转储是什么意思?