plist creatvoid plist head = NULL; list p1 p2; char a; a = getchar; whilea != n p1 = plistmallocsizeoflist; p1 - data = a; if head == NULL head = p1; else p2 - next = p1; p2 = p1; a
There seems to be a typo in the last line of the code. It should be "return head;" instead of "return headl;". Here is the corrected code:
plist creat(void)
{
plist head = NULL;
list *p1, *p2;
char a;
a = getchar();
while(a != '\n')
{
p1 = (plist)malloc(sizeof(list));
p1 -> data = a;
if (head == NULL)
{
head = p1;
}
else
{
p2 -> next = p1;
}
p2 = p1;
a = getchar();
}
p2 -> next = NULL;
return head;
}
AI 优化版
原文地址:https://www.cveoy.top/t/topic/iurd 著作权归作者所有。请勿转载和采集!