您在下面看到的这段代码是我项目的一部分。当我编译这段代码时,我得到了错误。错误是“从不兼容的指针类型传递'strcpy'的参数1”和预期的'char ',但参数的类型是'char * '。我该如何解决这个问题?谢谢你。
struct songs
{
char name[MAX];
double length;
struct songs *next;
};
typedef struct songs songs;
struct albums
{
char title[MAX];
int year;
char singerName[MAX];
songs *bas;
songs *current;
struct albums *next;
};
void add(char albumTitle[],char singerName[], int releaseYear )
{
struct albums *temp;
temp=(struct albums *)malloc(sizeof(struct albums));
strcpy( temp->title, albumTitle ); /* ERROR */
temp->year=releaseYear;
strcpy( temp->singerName, singerName ); /* ERROR */
if (head== NULL)
{
curr=head=temp;
head->next=NULL;
curr->next=NULL;
}
else
{
curr->next=temp;
curr=temp;
}
printf("Done\n");
}