【图书管理系统】

"book book books"

Posted by 2024级软件工程01班罗杰 on December 14, 2024

作品简介

图书管理系统
能实现登录、注册,有着账号权限。
操作上有借阅、归还、和搜索书籍及查看库存等基本功能。


程序特色

查看库存:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
void lookall()//查看库存
{
    struct Book *p;
    p=&book;
    FILE * file;
    file=fopen("书籍库存信息.txt","r");
    if(file==NULL)
    {
        printf ("文件丢失,请检查‘书籍库存信息.txt’");
    }
    while(!feof(file))
    {
        fscanf (file,"%s %s %s %d %d",p->name,p->author,p->number,&p->coin,&p->status);
        printf ("《%s》%s %s  ",p->name,p->author,p->number);
        switch(p->status)
            {
                case 0 : printf ("未借出\n\n");
                break;
                case 1 : printf ("已借出\n\n");
            }
    }
}

查找书籍:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
void findbook()//查找书籍
{
    int t=0;
    struct Book findbook;
    struct Book *p;
    p=&findbook;
    printf ("请输入书名:");
    scanf ("%s",book.name);
    printf ("\n");
    FILE * file;
    file=fopen("书籍库存信息.txt","r");
    if(file==NULL)
    {
        printf ("文件丢失,请检查‘书籍库存信息.txt’");
    }
    while(!feof(file))//循环读取直到文件结束
    {
        fscanf (file,"%s %s %s %d %d",p->name,p->author,p->number,&p->coin,&p->status);
        if (strcmp(p->name,book.name)==0)
        {
            t++;
            printf ("《%s》 %s %s  ",p->name,p->author,p->number);
            switch(p->status)
            {
                case 0 : printf ("未借出\n\n");
                break;
                case 1 : printf ("已借出\n\n");
            }
        }
    }
    fclose (file);
    if (t==0)
    {
        printf ("未找到此书\n\n");
    }
    else
        printf ("找到%d个结果\n\n",t);
    while(1)
    {
        printf("1-前往借阅     2-返回菜单\n\n");
        printf ("继续操作:");
        scanf("%d",&t);
        printf ("\n");
        switch(t)
        {
            case 1 : switch(user.usertype)
                         {
                              case 'A' :
                              case 'B' : borrowbook();
                              break;
                              default : printf ("请先登录\n\n");
                              k=0;
                         }
            break;
            case 2 : ;
            break;
            default : printf ("出错了,重新选择\n\n");
        }
        if(t==1||t==2)
        {
            break;
        }
    }
}

演示视频