【发布时间】:2016-01-16 13:14:09
【问题描述】:
我看到其他一些帖子也有同样的问题;然而,其他帖子建议使用 strcpy()。问题是我正在使用 strcpy() 并且我仍然收到此错误。如果有人可以帮助我解决这个问题,我将不胜感激。生病发布我的结构和我遇到问题的代码。
struct movie {
struct movie* next;
struct actor* actors;
char name[100];
int rating;
genre type;
}*list = NULL;
struct actor {
struct actor* next;
char name[100];
};
// Here is the code block i am having troubles with
int add_actor(char* movie_name, char* actor_name)
{
struct movie *temp = list;
struct movie *actor = (struct movie *) malloc(sizeof(struct movie));
while (temp != NULL)
{
if ((strcmp(temp->name, movie_name) == 0))
{
strcpy(list->actors->name, actor_name);
return 1;
}
temp = temp->next;
}
return 0;
}
【问题讨论】:
-
仍然缺少结构演员
-
对不起,我一定错过了这里生病编辑帖子
-
@milevyo 好吧,那里的结构正确
标签: c linked-list structure strcpy