Getting segmentation fault strcpy [duplicate]
问题 This question already has answers here : Segmentation Fault in strcpy() (3 answers) Closed 4 years ago . struct Object * newObj(char * nome, int idade, float altura) { struct Object *obj = (struct Object *) malloc(sizeof(struct Object)); strcpy(obj->nome, nome); // This is the line obj->idade = idade; obj->altura = altura; return obj; } This is my code, I don't know why I'm getting segmentation fault in strcpy. Any ideas? Thanks in advance. 回答1: In your struct Object type, the nome member is