人事管理系統

#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
#include <dir.h>
#include <dos.h>
#define CURYEAR 2003

struct date1
{
    int year;
    int month;
    int day;
};

struct employee
{
    char name[20];                /*  職工姓名  */
    int number;                   /*  職工序號 */
    char sex;                     /*  職工性別 */
    char rank;                    /*  職工職稱(p->教授,l->講師,a->副教授 */
    char department[20];          /*  職工所在部門 */
    int money;                    /*  職工工資 */
    struct date1 birthday;         /*  職工生日 */
    struct date1 workdate;         /*  職工工作時間 */
    struct employee *next;        /*  結點指針 */
};

char *sFileName = "e://personal.txt";
FILE *pFile;

char cover( void );
int input(void);
int output(void);
int find(void);
int erase(void);
int add(void);
int modify(void);
int statistic(void);
void help( void );
int quit(void);

int main(void)
{
    int iRCover;
    do
    {
        iRCover = cover();
        clrscr();
        switch (iRCover)
        {
            case 5:/* 輸入 */
                input();
            break;
            case 6:/* 輸出 */
                output();
            break;
            case 10:/* 查找(按姓名 || 按學號) */
                find();
            break;
            case 7:/* 修改 */
                modify();
            break;
            case 9:/* 刪除 */
                erase();
            break ;
            case 8:/* 添加 */
                add();
            break;
            case 11:/* 統計 */
                statistic();
            break;
            case 12:/* 幫助 */
                help();
            break;
            case 13:/* 退出 */
                system("cls");
                exit(1);
            break;
        }/* end of switch ... case */
    }while ( 1 );/* end of do ... while */
}

int GetKey( void ) /*獲得鍵盤掃描碼*/
{
    union REGS rg;

    rg.h.ah = 0;
    int86(0x16, &rg, &rg);

    return rg.h.ah;
}

void drawDia( void ) /*輸出紅色對話框*/
{
    window(25, 8, 55, 16);
    textbackground(RED);
    textcolor(WHITE);
    clrscr();
}

void revert( void )/* 還原屏幕,消除對話框帶來的負面影響 */
{
    window(1, 1, 80, 25);
    textbackground(BLACK);
    textcolor(WHITE);
    clrscr();
}

char cover( void )/*功能選擇面板*/
{
    int key = 0;
    int down = 5;
   
    revert();
    gotoxy(17, 5);
    printf("  I -----------> input the information   ");
    gotoxy(17, 6);
    printf("  O -----------> output all information  ");
    gotoxy(17, 7);
    printf("  M -----------> modify the information  ");
    gotoxy(17, 8);
    printf("  A -----------> add the information     ");
    gotoxy(17, 9);
    printf("  E -----------> delete the information  ");
    gotoxy(17, 10);
    printf("  F -----------> find the information    ");
    gotoxy(17, 11);
    printf("  S -----------> statistic of the information");
    gotoxy(17, 12);
    printf("  H -----------> help of the system      ");
    gotoxy(17, 13);
    printf("  Q -----------> quit the system         ");

    gotoxy(19, 5);
    do{
        key = GetKey();

        if (key == 80)/* 向下 */
        {
            down = down == 13 ? 5 : down + 1;
            gotoxy(19, down);
        }
        else if (key == 72)/* 向上 */
        {
            down = down == 5 ? 13 : down - 1;
            gotoxy(19, down);
        }
        else if (key == 28)/* 回車 */
        {
            return down;
        }
    }while ( 1);
}/*end of cover(...)*/

/*******************************************************************************

 *輸入函數

 *完成功能:讓用戶在提示下輸入系統所需信息(所有信息都暫存於鏈表中)
            完成對職工信息的錄入,並將其存放到指定文件中。

 *******************************************************************************/
int input(void)
{
    void ReadTab(void);
    void ReadData(struct employee *pLNode);

    struct employee *pLNode = NULL;
    int iTNumber = 0, i;

    clrscr();

    if (searchpath(sFileName) != NULL)/* 已存在文件時,input()函數不可用 */
    {
        drawDia();

        gotoxy(1, 2);
        printf("There is almost a exist file!");
        gotoxy(1, 4);
        printf("You can't use this function!");
        gotoxy(1, 6);
        printf("Press any key to return!");
        getch();

        return (0);
    }

    /* 要求輸入信息總數 */
    drawDia(); /* 一個對話框 */

    gotoxy(1, 2);/* 注意gotoxy(x, y)中座標爲相對座標(相對最近一個window()) */
    printf("Please input the total number");
    gotoxy(1, 4);
    printf("of the workers' information:");
    gotoxy(1, 6);
    scanf("%d", &iTNumber);

    revert();/*還原屏幕*/
    pLNode = (struct employee *)malloc(sizeof(struct employee));
    /* 讀取數據並存盤 */
    pFile = fopen(sFileName, "wb");
    for (i = 0; i < iTNumber; i++)
    {
        clrscr();
        gotoxy(4, 3);
        printf("The number of information you are inputting is %d !", i + 1);

        ReadTab();
        ReadData(pLNode);

        fwrite(pLNode, sizeof(struct employee), 1, pFile);/* 寫文件 */
    }
    fclose(pFile);
    free(pLNode);
    pLNode = NULL;/* 防止野指針 */

    return (1);
}

/**************************

 *打印輸入提示符

 *************************/
void ReadTab(void)
{
    gotoxy(8, 5);
    puts("Name :");/* string */
    gotoxy(8, 7);
    puts("Number :"); /* int */
    gotoxy(8, 9);
    puts("Sex(F&M) :");  /* char */
    gotoxy(8, 11);
    puts("Rank(P&L&A) :");  /* char */
    gotoxy(8, 13);
    puts("Department :"); /* string */
    gotoxy(8, 15);
    puts("Wage :"); /* int */
    gotoxy(8, 17);
    puts("Birthday");
    gotoxy(8, 18);
    puts("(yyyy mm dd) :"); /* struct date */
    gotoxy(8, 20);
    puts("WorkDate");
    gotoxy(8, 21);
    puts("(yyyy mm dd) :");  /* struct date */
}

/*******************

 *得到輸入數據

 *******************/
void ReadData(struct employee *pLNode)
{
    gotoxy(14, 5);
    scanf("%s", pLNode->name);
    gotoxy(16, 7);
    scanf("%d", &pLNode->number);
    gotoxy(18, 9);
    getchar();          /* 取消回車符的錄入 */
    pLNode->sex = getchar();
    gotoxy(21, 11);
    getchar();
    pLNode->rank = getchar();
    gotoxy(20, 13);
    scanf("%s", pLNode->department);
    gotoxy(14, 15);
    scanf("%d", &pLNode->money);
    gotoxy(17, 17);
    scanf("%d%d%d", &pLNode->birthday.year, &pLNode->birthday.month, &pLNode->birthday.day);
    gotoxy(17, 20);
    scanf("%d%d%d", &pLNode->workdate.year, &pLNode->workdate.month, &pLNode->workdate.day);
}

/************************

 *格式化輸出數據

 ************************/
int output()
{
    int display(struct employee *pLNode, int line);

    int line = 3;
    struct employee *pLNode = NULL;

    clrscr();

    pFile = fopen(sFileName, "rb");
    if (pFile == NULL)
    {
        printf("can't open the file!");
        puts("press any key to return!");
        return (0);
    }

    gotoxy(1, 2);
    puts("Name");
    gotoxy(15, 2);
    puts("Number");
    gotoxy(25, 2);
    puts("Sex");
    gotoxy(30, 2);
    puts("Rank");
    gotoxy(37, 2);
    puts("Department");
    gotoxy(50, 2);
    puts("Wage");
    gotoxy(58, 2);
    puts("Birthday");
    gotoxy(70, 2);
    puts("WorkDate");

    /*開闢緩衝空間 */
    pLNode = (struct employee *)malloc(sizeof(struct employee));
    while (!feof(pFile))
    {
        /* 讀文件 */
        if (fread(pLNode, sizeof(struct employee), 1, pFile) != 1)/* 1是所讀數據快的個數 */
            break;
        /* 顯示 */
        display(pLNode, line);
        ++line;
    }
    fclose(pFile);

    gotoxy(2, 25);
    printf("Press any key to return!");
    getch();

    free(pLNode);
    pLNode = NULL;/* 防止野指針 */

    return (1);
}

int display(struct employee *pLNode, int line)
{
    gotoxy(1, line);
    printf("%s", pLNode->name);
    gotoxy(15, line);
    printf("%d", pLNode->number);
    gotoxy(25, line);
    printf("%c", pLNode->sex);
    gotoxy(30, line);
    printf("%c", pLNode->rank);
    gotoxy(37, line);
    printf("%s", pLNode->department);
    gotoxy(50, line);
    printf("%d", pLNode->money);
    gotoxy(58, line);
    printf("%d/%d/%d", pLNode->birthday.year, pLNode->birthday.month, pLNode->birthday.day);
    gotoxy(70, line);
    printf("%d/%d/%d", pLNode->workdate.year, pLNode->workdate.month, pLNode->workdate.day);
}

/*******************************************************************************

 *查找函數

 *調用方式:find();

 *函數功能:按職工的序號進行查找,若找到,則輸出該同志的相關信息;
                  否則,輸出提示信息(如:not found!)。

 *******************************************************************************/
int find( void )
{
    void show(struct employee *pLNode);
    void findDia(int *flag, char *sTmpName, int *iTmpNum);

    struct employee *pLNode;
    int iTmpNum = 0, flag = 3;
    char *sTmpName = 0;

    findDia(&flag, sTmpName, &iTmpNum);

    pFile = fopen(sFileName, "rb");
    pLNode = (struct employee *)malloc(sizeof(struct employee));

    while (!feof(pFile))
    {
        /* 讀文件 */
        if (fread(pLNode, sizeof(struct employee), 1, pFile) != 1)
            break;
        /* 按姓名 */
        if ((flag == 0) && (strcmp(sTmpName, pLNode->name) == 0))
        {
            flag = 2;
            show(pLNode);
        }
        /* 按學號 */
        if ((flag == 1) && (iTmpNum == pLNode->number))
        {
            flag = 2;
            show(pLNode);
        }
    }/*end of while*/
    fclose(pFile);

    if (flag != 2)/* 沒找到 */
    {
        drawDia();

        gotoxy(1, 2);
        printf("No that person!");
        gotoxy(1, 4);
        printf("The file don't include that");
        gotoxy(1, 6);
        printf(" information!");
        gotoxy(1, 8);
        printf("Press any key to return!");
        getch();

        pLNode = NULL;
    }

    free(pLNode);
    pLNode = NULL;/* 防止野指針 */
    return (1);
}

/*****************************************

 *要求用戶輸入查找時信息的對話框

 *因爲本函數中用到了輸入輸出參數,所以不用返回值

 *******************************************/
void findDia(int *flag, char *sTmpName, int *pTmpNum)
{
    char *sFindFiled = 0;

    drawDia();

    gotoxy(1, 2);
    printf("Sort for name or number?");
    scanf("%s", sFindFiled);

    if (strcmp(sFindFiled, "name") == 0)
        (*flag) = 0;
    else if (strcmp(sFindFiled, "number") == 0)
        (*flag) = 1;
    else
        return;

    if ((*flag) == 0)/* 按名字 */
    {
        gotoxy(1, 4);
        printf("Please input name:");
        scanf("%s", sTmpName);
    }
    else/* 按學號 */
    {
        gotoxy(1, 4);
        printf("Please input number:");
        scanf("%d", pTmpNum);
    }
}

/*************************

 *顯示pLNode中的內容

 *************************/
void show(struct employee *pLNode)
{  
    revert();

    /* 輸出表單 */
    gotoxy(3, 2);
    puts("The information of your wonder is : ");
    gotoxy(4, 4);
    puts("Name :");
    gotoxy(4, 6);
    puts("Number :");
    gotoxy(4, 8);
    puts("Sex :");
    gotoxy(4, 10);
    puts("Rank :");
    gotoxy(4, 12);
    puts("Department :");
    gotoxy(4, 14);
    puts("Wage :");
    gotoxy(4, 16);
    puts("Birthday :");
    gotoxy(4, 18);
    puts("Workdate :");

    /* 輸出數據 */
    gotoxy(10, 4);
    printf("%s", pLNode->name);
    gotoxy(12, 6);
    printf("%d", pLNode->number);
    gotoxy(9, 8);
    printf("%c", pLNode->sex);
    gotoxy(10, 10);
    printf("%c", pLNode->rank);
    gotoxy(16, 12);
    printf("%s", pLNode->department);
    gotoxy(10, 14);
    printf("%d", pLNode->money);
    gotoxy(14, 16);
    printf("%d/%d/%d", pLNode->birthday.year, pLNode->birthday.month, pLNode->birthday.day);
    gotoxy(14, 18);
    printf("%d/%d/%d", pLNode->workdate.year, pLNode->workdate.month, pLNode->workdate.day);

    gotoxy(4, 25);
    puts("Press any key to continue!");
    getch();

    return;
}

/*******************************************************************************

 *修改函數

 *調用方式:modify();

 *函數功能:對某職工的某條信息進行修改。要確定在數據文件中有該同志的信息資料,
                               若查找不到,則輸出提示信息(如:not found!)。

 *******************************************************************************/
int modify( void )
{
    void show(struct employee *pLNode);

    struct employee *pLNode = NULL, *pLHead = NULL, *pLModify = NULL;
    char *sTmpFiled = 0;/* 存放將要修改的域 */
    char *sTmpName = 0;/* 存放將要修改的姓名 */
    int flag = 0;/* 是否存在的標誌 */

    clrscr();
    drawDia();

    gotoxy(1, 1);
    printf("Who do you want to modify?");
    gotoxy(1, 2);
    scanf("%s", sTmpName);

    pFile = fopen(sFileName, "rb");
    /* 建立首節點 */
    pLHead = (struct employee *)malloc(sizeof(struct employee));
    pLHead->next = NULL;
    while (!feof(pFile))
    {
        pLNode = (struct employee *)malloc(sizeof(struct employee));
        /* 讀文件 */
        if (fread(pLNode, sizeof(struct employee), 1, pFile) != 1)
            break;
        /* 建立鏈表 */
        pLNode->next = pLHead->next;
        pLHead->next = pLNode;
        if (strcmp(sTmpName, pLNode->name) == 0)
        {
            flag = 1;/* 找到的話,置標誌 */
            pLModify = pLNode;/* 並賦值指針 */
        }
    }/*end of while*/

    fclose(pFile);

    if (flag == 1)/*  可以修改 */
    {
        char *sFiled[8] = {"name", "number", "sex", "rank", "department", "wage"
                        "birthday", "workdate"};
        int i = 0;

        gotoxy(1, 3);        /* 輸出對話框 */
        printf("And which filed ?");
        gotoxy(1, 4);
        printf("(name number sex rank workdate");
        gotoxy(1, 5);
        printf("department wage birthday)");
        gotoxy(18, 3);
        scanf("%s", sTmpFiled);
        gotoxy(1, 6);
        printf("The current data is : ");
        gotoxy(1, 7);

        while (strcmp(sTmpFiled, sFiled[i]) != 0)/* 檢驗是哪個域 */
            ++i;

        switch (i)
        {
        case 0: printf("%s", pLModify->name);
                gotoxy(1, 8);
                printf("Please input the new data :");
                gotoxy(1, 9);
                scanf("%s", pLModify->name);
                break;
        case 1: printf("%d", pLModify->number);
                gotoxy(1, 8);
                printf("Please input the new data :");
                gotoxy(1, 9);
                scanf("%d", &pLModify->number);
                break;
        case 2: printf("%c", pLModify->sex);
                gotoxy(1, 8);
                printf("Please input the new data :");
                gotoxy(1, 9);
                getchar();
                pLModify->sex = getchar();
                break;
        case 3: printf("%c", pLModify->rank);
                gotoxy(1, 8);
                printf("Please input the new data :");
                gotoxy(1, 9);
                getchar();
                pLModify->rank = getchar();
                break;
        case 4: printf("%s", pLModify->department);
                gotoxy(1, 8);
                printf("Please input the new data :");
                gotoxy(1, 9);
                scanf("%s", pLModify->department);
                break;
        case 5: printf("%d", pLModify->money);
                gotoxy(1, 8);
                printf("Please input the new data :");
                gotoxy(1, 9);
                scanf("%d", &pLModify->money);
                break;
        case 6: printf("%d/%d/%d", pLModify->workdate.year,
                                   pLModify->workdate.month,
                                   pLModify->workdate.day);
                gotoxy(1, 8);
                printf("Input new data:(yyyy mm dd)");
                gotoxy(1, 9);
                scanf("%d%d%d", &pLModify->workdate.year,
                                &pLModify->workdate.month,
                                &pLModify->workdate.day);
                break;
        case 7: printf("%d/%d/%d", pLModify->birthday.year,
                                   pLModify->birthday.month,
                                   pLModify->birthday.day);
                gotoxy(1, 8);
                printf("Input new data:(yyyy mm dd)");
                gotoxy(1, 9);
                scanf("%d%d%d", &pLModify->birthday.year,
                                &pLModify->birthday.month,
                                &pLModify->birthday.day);
                break;
        default: printf("No that filed!");
                gotoxy(1, 8);
                printf("Press any key to return!");
                return (0);
        }
    }
    else
    {
        gotoxy(1, 4);
        printf("No this person!");
        gotoxy(1, 6);
        printf("Press any key to return!");
        getch();

        return (0);
    }

    revert();

    /* 顯示新信息 */
    show(pLModify);

    /* 存盤 */
    pFile = fopen(sFileName, "wb");
    pLNode = pLHead->next;
    while (pLNode != NULL)
    {
        if (fwrite(pLNode, sizeof(struct employee), 1, pFile) != 1)
            break;

        pLNode = pLNode->next;
    }
    fclose(pFile);

    /* 釋放鏈表 */
    free(pLHead);
    pLHead = NULL;

    return (1);
}

/*******************************************************************************

 *添加函數

 *調用方法:add();

 *函數功能:在原數據文件中插入一條新職工信息。

 *******************************************************************************/
int add( void )
{
    void ReadData(struct employee *pLNode);
    void ReadTab(void);

    struct employee *pLNode = NULL, *pLHead = NULL;

    pFile = fopen(sFileName, "rb");
    /* 建立鏈表首節點 */
    pLHead = (struct employee *)malloc(sizeof(struct employee));
    pLHead->next = NULL;
    while (!feof(pFile))
    {
        pLNode = (struct employee *)malloc(sizeof(struct employee));

        if (fread(pLNode, sizeof(struct employee), 1, pFile) != 1)
            break;

        pLNode->next = pLHead->next;
        pLHead->next = pLNode;
    }
    fclose(pFile);

    /* 爲新增節點開闢空間 */
    pLNode = (struct employee *)malloc(sizeof(struct employee));
    pLNode->next = pLHead->next;
    pLHead->next = pLNode;

    clrscr();
    gotoxy(3, 3);
    printf("Please input the information you want to add : ");

    pLNode = pLHead->next;
    ReadTab();
    ReadData(pLNode);

    pFile = fopen(sFileName, "wb");
    pLNode = pLHead->next;
    while (pLNode != NULL)
    {
        if (fwrite(pLNode, sizeof(struct employee), 1, pFile) != 1)
            break;

        pLNode = pLNode->next;
    }

    fclose(pFile);
    free(pLHead);
    pLHead = pLNode = NULL;

    return (1);
}

/*******************************************************************************

 *刪除模塊

 *調用方式:erase();

 *函數功能:輸入要刪除職工姓名,在數據文件中查找該職工信息,找到後刪除;
                  若查找不到,則輸出提示信息(如:not found!)。

 *******************************************************************************/
int erase( void )
{
    void show(struct employee *pLNode);

    struct employee *pLNode = NULL, *pLHead = NULL;
    char *sTmpName = 0;
    int flag = 0;/* 是否存在的標誌 */

    clrscr();/* 使清屏 */
    drawDia();

    /* 輸入要刪除的職工姓名 */
    gotoxy(1, 2);
    printf("Who do you want to delete?");
    gotoxy(1, 4);
    scanf("%s", sTmpName);

    if ((pFile = fopen(sFileName, "rb")) == NULL)
    {
        gotoxy(1, 5);
        puts("Can't open the file!");
        gotoxy(1, 6);
        puts("Press any key to return!");
        getch();
        return (0);
    }

    pLHead = (struct employee *)malloc(sizeof(struct employee));
    pLHead->next = NULL;
    while (!feof(pFile))
    {
        int isFind = 0;

        pLNode = (struct employee *)malloc(sizeof(struct employee));

        if (fread(pLNode, sizeof(struct employee), 1, pFile) != 1)
            break;

        if (strcmp(sTmpName, pLNode->name) == 0)/* 存在此記錄 */
        {
            flag = 1;/* 置標誌1 */
            isFind = 1;/*是否找到標誌2*/
            show(pLNode);/* 顯示將要刪除的信息 */
            free(pLNode);
            pLNode = NULL;
        }

        if (isFind != 1)/*若果找到,則直接刪除節點*/
        {
            pLNode->next = pLHead->next;
            pLHead->next = pLNode;
        }
    }
    fclose(pFile);

    if (flag != 1)/* 不存在 */
    {
        drawDia();

        gotoxy(1, 2);
        printf("No that person!");
        gotoxy(1, 4);
        printf("The file don't include that");
        gotoxy(1, 6);
        printf(" information!");
        gotoxy(1, 8);
        printf("Press any key to return!");
        getch();

        return (0);
    }

    revert();

    gotoxy(3, 3);
    printf("The information you want to delete is :");

    /* 存盤 */
    pFile = fopen(sFileName, "wb");
    pLNode = pLHead->next;
    while (pLNode != NULL)
    {
        if (fwrite(pLNode, sizeof(struct employee), 1, pFile) != 1)/* 存盤 */
            break;

        free(pLNode);

        pLNode = pLNode->next;
    }
    fclose(pFile);

    clrscr();

    drawDia();

    gotoxy(1, 2);
    printf("The information has been ");
    gotoxy(1, 4);
    printf("deleted successfully!");
    gotoxy(1, 8);
    printf("Press any key to return!");
    getch();

    free(pLHead);
    pLHead = pLNode = NULL;

    return (1);
}

/*******************************************************************************

 *統計函數

 *調用方式:statistic();

 *函數功能:做職工卡片。
                統計教授(P)、講師(L)、副教授的人數(A)
                計算並打印今年的退休人員(男60 ,女55)及相關信息

 *******************************************************************************/
int statistic(void)
{
    void show(struct employee *pLNode);
    struct employee *pLNode, *pLHead;
    int nProfessor = 0, nLecture = 0, nAdjunct = 0;
    int nOldMen = 0, nOldWomen = 0;

    pFile = fopen(sFileName, "rb");/*讀文件並建立鏈表*/
    pLHead = (struct employee *)malloc(sizeof(struct employee));
    pLHead->next = NULL;
    while (!feof(pFile))
    {
        pLNode = (struct employee *)malloc(sizeof(struct employee));

        if (fread(pLNode, sizeof(struct employee), 1, pFile) != 1)
            break;

        pLNode->next = pLHead->next;
        pLHead->next = pLNode;
    }
    fclose(pFile);

    pLNode = pLHead->next; /*遍歷鏈表對數據進行統計*/
    while (pLNode != NULL)
    {
        /* 功能一 */
        if (pLNode->rank == 'p' || pLNode->rank == 'P')
        {
            ++nProfessor;
        }
        else if (pLNode->rank == 'l' || pLNode->rank == 'L')
        {
            ++nLecture;
        }
        else if (pLNode->rank == 'a' || pLNode->rank == 'A')
        {
            ++nAdjunct;
        }

        /* 功能二 */
        if ((pLNode->sex == 'm' || pLNode->sex == 'M') &&
            (CURYEAR -  pLNode->birthday.year > 60))
        {
            ++nOldMen;
        }

        if ((pLNode->sex == 'f' || pLNode->sex == 'F') &&
            (CURYEAR - pLNode->birthday.year > 55))
        {
            ++nOldWomen;
        }

        pLNode = pLNode->next;
    }

    clrscr();
    /* 顯示 */
    drawDia();

    gotoxy(1, 1);
    printf("There are the statistic: ");
    gotoxy(1, 2);
    printf("Professor : %d", nProfessor);
    gotoxy(1, 3);
    printf("Lecture : %d", nLecture);
    gotoxy(1, 4);
    printf("Adjunct : %d", nAdjunct);
    gotoxy(1, 5);
    printf("This year there will be ");
    gotoxy(1, 6);
    printf("%d  men retire", nOldMen);
    gotoxy(1, 7);
    printf("And %d women retire!", nOldWomen);
   
    gotoxy(1, 8);
    printf("Press any key to continue");
    getch();

    revert();

    /* 職工卡片 */
    pLNode = pLHead->next;
    while (pLNode != NULL)
    {
        clrscr();
        gotoxy(4, 1);
        puts("There are the employees' kard!");

        show(pLNode);

        pLNode = pLNode->next;
    }
    /* 釋放鏈表 */
    pLNode = pLHead->next;
    while (pLNode != NULL)
    {
        free(pLNode);

        pLNode = pLNode->next;
    }

    pLNode = pLHead = NULL;
    return (1);
}

/*******************************************************************************

 *幫助函數

 *調用方式:help();

 *函數功能:爲用戶提供必要的幫助說明,如:功能鍵的說明,
                                          關於系統的說明,
                                          系統的使用方式等等

 *******************************************************************************/
void help( void )
{
    FILE *pHelp;
    int line = 2, col = 2;
    char cTemp;

    clrscr();
    pHelp = fopen("e://endtemp//help.txt", "rb");

    if(pHelp == NULL)
    {
        printf("this file cannot open/n");
        getch();
        return;
    }
    while (((cTemp = fgetc(pHelp)) != EOF) && (col < 80) && (line < 23))
    {
        if (cTemp == '/n')
        {
            line++;
            col = 2;
        }
        gotoxy(col++, line);
        putchar(cTemp);
    }

    gotoxy(2, 25);
    printf("Press any key to return!");
    getch();
    fclose(pHelp);

    return;
}

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章