程序代码:
typedef struct linklist {
struct linklist * next;
} linklist, **ListHead;
linklist* initlist(linklist ** pp)
{
*pp = NULL;
return NULL;
}
linklist* insert(linklist **pphead)
{
linklist *pnewnode, *p;
pnewnode = (linklist*)malloc(sizeof(linklist));
pnewnode->next = NULL;
if (*pphead == NULL)
*pphead = p;
else
for (p = *pphead; p->next != NULL; p=p->next)
continue;
p->next = pnewnode;
return pnewnode;
}
int main(void)
{
ListHead head;
initlist(head);
insert(head);
insert(head);
return 0;
}
[
本帖最后由 cosdos 于 2011-6-19 02:29 编辑 ]