错误:'free'|

问题描述 投票:0回答:1
strutto *head,*cdm;

head=&a;
cdm=head;
a.next=&b;
b.next=&c;
c.next=NULL;

do{
    printf("%d\n",cdm->dato);
    cdm=cdm->next;
}   while(cdm!=NULL);

 free(a);
 free(b);
 free(c);

我在尝试释放列表时遇到此错误错误:“free”的参数 1 的类型不兼容|

stdlib 已包含在内

c list compiler-errors free
1个回答
0
投票

free() 接受指针参数,并且您传递的 a、b、c 不是指针。有问题的是,没有显示 a、b、c 从哪里出现。如果它们在堆栈上,那么您无法释放它。它们将随堆栈消失,无需释放。

© www.soinside.com 2019 - 2024. All rights reserved.