【发布时间】:2020-03-31 22:54:37
【问题描述】:
我正在尝试将名称分配给 TCP 服务器中的客户端,但 strcpy() 函数给我一个分段错误。
struct clients{
int client_fd;
char* name;
struct clients* next;
}
struct clients* first;
first->client_fd = 1;
first->name = NULL;
memset(&first->name, 0, sizeof(first->name));
first->name = (char*)malloc(100*sizeof(char));
strcpy(first->name, "User");
first->next = NULL;
【问题讨论】:
标签: c segmentation-fault