C语言实现文件存取信息的学生管理系统

这是一个利用C语言编写的、基于单链表实现的学生管理系统。系统能从文件中读取并存储学生信息,包括学号、姓名和成绩。支持的功能有:初始化(链表+文件读取)、添加学生、按学号删除和修改学生信息、查看特定学生信息、显示所有学生信息以及退出时更新文件。初次运行需创建包含0的StuNum.txt文件。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

C语言实现的一个使用单链表的学生管理系统,使用文件存储学生信息,结构体中包括学号、姓名和成绩,实现的功能有系统初始化(创建链表,读取文件中的信息到链表),添加学生记录,根据学号删除学生记录,根据学号修改学生信息(不能修改学号),根据学号查看学生信息,显示所有学生信息以及退出系统(将学生信息写入文件)。代码多有不足,请大家多多指教,有关于代码的问题可以私信我或者在评论区评论。

注意:该项目第一次运行,需要在项目根目录下新建一个StuNum.txt文件,在文件中写入0;

studentsystem.h

#include <stdio.h>
#include <string.h>
#define MaxSize 26
//声明文件指针
FILE *fp1,*fp2,*fp3,*fp4;
//链表节点,存放学生信息
typedef struct studentNode
{
 int no;
 char name[MaxSize];
 int score;
 struct studentNode *next;
}stuNode;
//链表头指针
stuNode* Head;
//初始化链表
stuNode* InitLinkList();
//新建结点
stuNode* ListInsert(int no,char name[MaxSize],int score);
//删除结点
int DeleteList(stuNode* head,int no);
//修改结点信息
int ChangeList(stuNode* head,int no,stuNode*);
//改变新修改结点位置
int Changeposition(stuNode* head,int no);
//查找结点
int SearchList(stuNode* head,int no);
//读文件
int Readfile(stuNode* head);
//写文件
int Writefile(stuNode* head);
//主界面
int MainMenu();
//添加
int Add(stuNode *head);
//删除
int Delete();
//修改
int Change();
//查找
int Search();
//显示学生信息
int Show(stuNode* head);
//系统初始化
int SystemInit();
//退出系统
int exitsystem();

studentsystem.c

#include <stdio.h>
#include <stdlib.h>
#include "studentsystem.h"
//初始化链表,为链表头指针分配空间,读取学生记录个数
stuNode* InitLinkList()
{
    stuNode* head = (stuNode*)malloc(sizeof(stuNode));
    head->no = 16;
    strcpy(head->name,"BigData");
    fscanf(fp1,"%d",&head->score);
    head->next = NULL;
    return head;
}
//创建节点
stuNode* ListInsert(int no,char name[MaxSize],int score)
{
    stuNode* newnode = (stuNode*)malloc(sizeof(stuNode));
    newnode->no = no;
    strcpy(newnode->name,name);
    newnode->score = score;
    newnode->next = NULL;
    return newnode;
}
//从链表中删除结点
int DeleteList(stuNode* head,int no)
{
    stuNode *p,*q,*t;
    p = q 
纯C语言学生成绩管理系统(以包含文件的形式写的),结构体,链表,数组,以下是main.c #include #include #include #define m 3/*宏定义m的值为3*/ struct node/*链表初始化*/ { char name[20]; int no; float score[m]; float sum; float avg; struct node *next; }; char ch[m+4][20]={{"学号"},{"姓名"},{"语文"},{"数学"},{"英语"},{"总分"},{"平均分"}};/*定义初始化一个全局二维字符数组*/ #include "save.c"/*包含保存文件*/ #include "read.c"/*包含读取文件*/ #include "output.c"/*包含打印文件*/ #include "set.c"/*包含录入文件*/ #include "demand.c"/*包含查询文件*/ #include "sort.c"/*包含排序文件*/ #include "modified.c"/*包含修改文件*/ #include "add.c"/*包含添加文件*/ #include "del.c"/*包含删除文件*/ void main() { int n; printf("\n\t\t\t欢迎使用学生成绩管理系统\n\n"); printf("\t\t\t\t\t\t制 作: XIA XIA\n"); do { printf("\n\n1:学生成绩录入,保存\n"); printf("2:学生成绩查询\n"); printf("3:学生成绩的排序\n"); printf("4:学生成绩的修改\n"); printf("5:学生成绩的打印\n"); printf("6:学生信息的添加\n"); printf("7:学生信息的删除\n"); printf("0:退出学生成绩管理系统\n\n\n"); printf("输入你要执行操作的相应序号\n"); scanf("%d",&n);/*输入相就的操作的序号*/ switch (n) { case 1: set();break;/*调用录入函数*/ case 2: demand();break;/*调用查询函数*/ case 3: sort();break;/*调用排序函数*/ case 4: modified();break;/*调用修改函数*/ case 5: output();break;/*调用打印函数*/ case 6: add();break;/*调用添加函数*/ case 7: del();break;/*调用删除函数*/ case 0: printf("正在退出学生成绩管理系统......\n");exit(0);/*直到输入“0”退出学生成绩管理系统*/ default:printf("输入错误码,请重新输入\n"); } }while(1); }
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值