0
我写这个函数删除链表的元素:按一定标准
List* delPaintingCode(List* head, char *code)
{
List *p,*q;
for(p=head;p!=NULL;q=p,p=p->next)
{
if(!strcmp(code,p->code))
{
if (p==head)
{
q=head;
head=p->next;
free(q);
}
else
{
q->next=p->next;
free(p);
p=q;
}
}
}
return head;
}
,当我把它在另一个功能:
void delpainting()
{
char code[50];
printf("code ");
scanf("%s",code);
List *head=NULL;
head=delPaintingCode(filetolist,code);
}
程序崩溃等等。我有一个警告:passing argument 1 of delPaintingCode from incompatible pointer type
那么我应该如何将字符串传递给函数呢?
什么是'filetolist'? – mtijanic
“我应该如何将字符串传递给函数” - 它看起来像你应该问“我应该将哪个'List'指针传递给函数,这个警告不是随机的。 – WhozCraig