报错:a function-definition is not allowed here before‘{’token、
#include <stdio.h>#include <stdlib.h>
int main()
{
typedef struct Node
{
int data;
struct Node *pNode;
}NOD, * PNODE;
PNODE create_list(void)
{
int len;
int i;
int val;
PNODE pHead = (PNODE)malloc(sizeof(NOD));
if (NULL == pHead)
{
printf("分配失败,程序终止!\n");
exit(-1);
}
PNODE pTail = pHead;
pTail->pNode = NULL;
printf("请输入您需要生成的链表的节点个数:len = ");
scanf("%d", &len);
for (i = 0; i < len; ++i)
{
printf("请输入第%d个节点的值: ", i+1);
scanf("%d", &val);
PNODE pNew = (PNODE)malloc(sizeof(NOD));
if (NULL == pNew)
{
printf("分配失败,程序终止!\n");
exit(-1);
}
pNew ->data = val;
pTail ->pNode = pNew;
pNew ->pNode = NULL;
pTail = pNew;
}
return pHead;
};
}