【C语言】实验室设备管理系统

这是一个使用C语言编写的实验室设备管理系统,包括设备的录入、修改、分类统计和查询功能。系统存储设备信息如编号、种类、名称、价格等,并采用文件方式保存数据。由于对设备破损耗费和遗损处理的理解不明确,作者仅实现了设备破损情况的记录。
摘要由CSDN通过智能技术生成

实验室设备管理系统

题目要求

实验设备管理系统设计
实验设备信息包括:设备编号,设备种类(如:微机、打印机、扫描仪等等),设备名称,设备价格,设备购入日期,是否报废,报废日期等。
主要功能:
(1)能够完成对设备的录入和修改
(2)对设备进行分类统计
(3)设备的破损耗费和遗损处理
(4)设备的查询
要求:使用文件方式存储数据。

源代码

#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#include<malloc.h>
#include<windows.h>
#include<conio.h>

/*定义存放仪器信息的结构体*/
typedef struct Information
{
   
	char Name[20];       //仪器名称
	char Sort[2];        //仪器种类
	char ID[20];         //仪器编号
	char Price[20];      //仪器价格
	char Buydate[20];    //设备购买日期
	char State[2];       //设备状态
	char Donatedate[20]; //报废日期
	struct Information* next;
} Information;

/*定义文件*/
FILE* fp;

/*读出文件信息*/
Information* Fscanf()
{
   
	Information* head = (Information*)malloc(sizeof(Information));
	head->next = NULL;
	FILE* fp = fopen("Equipment.txt", "rt");
	if (fp == NULL)
	{
   
		puts("文件打开失败");
		exit(1);   //程序异常退出
	}
	if (fscanf(fp, "%s %s %s %s %s %s %s", head->Name, head->Sort, head->ID, head->Buydate, head->Price, head->State, head->Donatedate) != EOF)
	{
   
		while (fgetc(fp) != EOF)  //判断是否已经到文件尾部了
		{
   
			Information* cur = (Information*)malloc(sizeof(Information));
			fscanf(fp, "%s %s %s %s %s %s %s", cur->Name, cur->Sort, cur->ID, cur->Buydate, cur->Price, cur->State, cur->Donatedate);
			cur->next = head;
			head = cur;
		}  //利用头插法将文件读入链表中
	}
	else
		return NULL;
	fclose(fp);
	return head->next;
}

/*存入文件*/
void Fprintf(Information* head)
{
   

	if ((fp = fopen("Equipment.txt", "w")) == NULL)
	{
   
		printf("\n\n文件打开失败!\n");
		exit(1);
	}
	Information* cur = head;
	while (cur)
	{
   
		fprintf(fp, "%s %s %s %s %s %s %s\n", cur->Name, cur->Sort, cur->ID, cur->Buydate, cur->Price, cur->State, cur->Donatedate);
		cur = cur->next;
	}
	fclose(fp);
}

/*目录*/
Information* Addition(Information* head);//添加设备信息
Information* Query(Information* head);//查找设备信息
Information* Modify(Information* head);//修改仪器信息
Information* Delect(Information* head);//删除仪器信息
void Over();//结束系统
void Menu();//系统目录


/*添加设备信息*/
Information* Addition(Information* head)
{
   
	int n, count = 0;
	printf("\n请输入要添加的设备数量:");  //请输入要添加的设备数量
	scanf("%d", &n);
	system("cls");  //清屏操作
	while (n--)
	{
   
		Information* cur 
  • 18
    点赞
  • 143
    收藏
    觉得还不错? 一键收藏
  • 15
    评论
评论 15
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值