由于总代码长度过长,显示部分代码块。
/*将文件内的内容读入到链表中*/
struct worker_link *pNew;
struct worker_link *pTail = NULL;
char eat = ' ';
while (!feof(fp1))
{
pNew = (struct worker_link *)malloc(sizeof(struct worker_link));
if(pNew == NULL)
{
printf("Error!");
exit(-1);
}
fscanf(fp1, "%s%c%s%c%c%c%d%c%s%c%s%c", pNew->work_num, &eat, pNew->name, &eat, &pNew->sex, &eat, &pNew->position_num, &eat, pNew->birthday, &eat, pNew->add, &eat);
if(pHead == NULL)
pHead = pNew;
else
pTail->pNext = pNew;
pTail = pNew;
}
pTail->pNext = NULL; //链表结尾要把尾指针的pNext指针置空
p = pHead;
fclose(fp1);