DavidOK, am I correct in understanding that I should be changing the codeas follows?member->firstName = calloc(strlen(fname)+1, sizeof(char));Notice I removed the (char *) from in front of calloc. Actually,leaving it there is how any example in class had it. So I am confused.I did also mean the program crashes, not the compiler stops. I am tootired to think clearly tonight.By the way, I just recompiled and ran the program by removing the(char *) cast, but the same seg fault error is still there. I willneed to review my code more.Also, I am including the stdlib.h library in my header.David 这篇关于将内存分配给结构中的char *变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云! 07-30 15:29