编程论坛's Archiver

gdzhan 发表于 2007-5-22 12:21

学生信息管理系统(C结构体版),第一次写这程序

<P>自学了两个月,,刚学结构体,写了个这种程序,呵呵,,还有很多错的地方还请各位看过的帮我指点一下错误,<BR>,,,,,,自学真痛苦阿,,,,,,<BR><BR>/*****************************************************************/<BR>//              学生学籍管理系统v1.0测试版.      <BR>//              开发者:☆ゞ天涯☆ゞ。           <BR>//              开发时间:2007-05-15             <BR>//              系统登陆密码:521314 <BR>//              QQ: 214880229                    <BR>/*****************************************************************/</P>
<P>#include &lt;stdio.h&gt;<BR>#include &lt;stdlib.h&gt;<BR>#include &lt;string.h&gt;<BR>#include &lt;conio.h&gt;<BR>#include &lt;time.h&gt;</P>
<P>#define NAME       20<BR>#define SEX        10<BR>#define BIRTH      20<BR>#define ADDDR      30<BR>#define POTO       12<BR>#define DAK        10<BR>#define SCHOOL     30<BR>#define SORC       6<BR>#define STUDENTMAX 1000                                      //学生最大人数 <BR>#define PASSWORD "521314"                                    //系统登陆密码 </P>
<P>/************************学生信息结构体**********************/ <BR>struct studentinfo                                           //学生个人信息结构<BR>{<BR>    char name  [NAME];                                       //学生姓名<BR>    char sex   [SEX];                                        //学生性别<BR>    char birth [BIRTH];                                      //出生日期<BR>    char adddr [ADDDR];                                      //学生地址<BR>    char poto  [POTO];                                       //联系电话<BR>    char dak   [DAK];                                        //邮证编码 <BR>    char school[SCHOOL];                                     //所在学校  <BR>};<BR>struct studentsorc                                           //学生成绩结构<BR>{<BR>    char name[NAME];                                         //学生姓名 <BR>    int   ID;                                                //学生学号 <BR>    float sorc[6];                                           //记录学生成绩<BR>    float aver;                                              //平均分 <BR>    float sum;                                               //总分  <BR>};<BR>struct allstudentinfo                                        //学生全部结构 <BR>{<BR>    struct studentinfo student;<BR>    struct studentsorc student1;  <BR>}; </P>
<P>FILE *infofile=NULL;                                         //存学生个人信息数据文件<BR>FILE *sorcfile=NULL;                                         //存学生成绩数据文件<BR>char filename[]="c:\\学生个人信息登记.dat";                  //记录个人信息登记<BR>char filename1[]="c:\\学生成绩.dat";                         //记录学生成绩 <BR> <BR>/************************函数块声明****************************/ </P>
<P>void password();                                            //密码验证<BR>int  showmeun();                                            //系统主菜单显示<BR>int  submeun();                                             //子菜单显示 <BR>void sorcmeun(struct allstudentinfo *);                     //成绩管理子菜单 <BR>void submain(struct allstudentinfo *);                      //子系统 <BR>void inputinfo(struct allstudentinfo *);                    //输入学生个人信息<BR>void modinfo(struct allstudentinfo *);                      //修改个人信息<BR>void aboutinfo(struct allstudentinfo *);                    //查询个人信息<BR>void allabout(struct allstudentinfo *);                     //查询所有信息 <BR>void delinfo(struct allstudentinfo *);                      //删除个人信息<BR>void mofname(struct allstudentinfo *);                      //修改姓名<BR>void mofsex(struct allstudentinfo *);                       //修改性别<BR>void mofbirth(struct allstudentinfo *);                     //修改出生日期<BR>void mofadddr(struct allstudentinfo *);                     //修改家庭住址<BR>void mofpoto(struct allstudentinfo *);                      //修改电话号码<BR>void mofdak(struct allstudentinfo *);                       //修改邮证编码<BR>void mofschool(struct allstudentinfo *);                    //修改所在院校<BR>int datfile(struct allstudentinfo *);                       //处理修改个人信息的文件<BR>void inputsorc(struct allstudentinfo *);                    //个人成绩录入 <BR>void mofsorc  (struct allstudentinfo *);                    //修改成绩 <BR>void seasorc  (struct allstudentinfo *);                    //查找个人成绩 <BR>void seaallsorc(struct allstudentinfo *);                   //浏览所有成绩 <BR>void delsorc  (struct allstudentinfo *);                    //删除成绩 <BR>int sorcdatfile(struct allstudentinfo *);                   //成绩数据文件 <BR>void systemhelp();                                          //系统帮助信息 </P>
<P>int main(void)<BR>{<BR>    struct allstudentinfo studentmax[STUDENTMAX];           //最大学生人数<BR>    struct allstudentinfo *p_student;                       //指向结构指针<BR>    int    in;<BR>    time_t start,end;<BR>    <BR>    p_student=studentmax;                                   //指向结构体 <BR>    password();                                             //获取用户密码验证<BR>    <BR>    do<BR>    {<BR>        system("cls");<BR>        in=showmeun();                                      //系统主菜单显示 <BR>        switch(in)<BR>        {<BR>            case 1 : submain(p_student);                <BR>                     break;<BR>            case 2 : sorcmeun(p_student);<BR>                     break;<BR>            case 3 : systemhelp();<BR>                     break;<BR>            case 4 : break;<BR>             <BR>            default: printf("没有此选项,请按任意键返回重新选择!");<BR>                     getch();<BR>                     system("cls");<BR>                     break; <BR>        }<BR>    }while(in!=4);<BR>    system("cls");<BR>    printf("\n\n\n\n\n\n\n\n\t\t\t");<BR>    printf("谢  谢  使  用  本  系  统  !"); <BR>    start=time(NULL);<BR>    end=time(NULL);<BR>    while(end-start&lt;1.5)<BR>        end=time(NULL);<BR>    return 0;<BR>}</P>
<P>/************************子系统*******************************/<BR>void submain(struct allstudentinfo *p_student)<BR>{<BR>    int  in;<BR>    <BR>    do<BR>    {<BR>        system("cls");<BR>        in=submeun();                                                    //子菜单显示 <BR>        switch(in)<BR>        {<BR>            case 1 : inputinfo(p_student);                               //输入个人信息<BR>                     break;<BR>            case 2 : modinfo(p_student);                                 //修改个人信息<BR>                     break;<BR>            case 3 : aboutinfo(p_student);                               //查询个人信息<BR>                     break;<BR>            case 4 : allabout(p_student);                                //查询所有信息<BR>                     break;<BR>            case 5 : delinfo(p_student);                                 //删除个人信息<BR>                     break;<BR>            case 6 : break;<BR>             <BR>            default: printf("没有此选项。请您重新输入(1-5)");<BR>                     getch();<BR>                     system("cls");<BR>                     break;<BR>        }<BR>    }while(in!=6);<BR>    system("cls");<BR>    return ;<BR>} </P>
<P>/************************密码验证*****************************/<BR>void password()<BR>{<BR>    char *pass=NULL;                                        //初始化指针 <BR>    int  count;<BR>    time_t start,end;                                       //时间函数<BR>    <BR>    pass=(char *)malloc(255*sizeof(char));                  //分配内存 <BR>    while(1)<BR>    { <BR>        count=0; <BR>        printf("\n\n\n\n\n\t\t         学生信息管理系统Ver1.0测试版     \n");<BR>        printf("\n\t\t               用户名:TIANYA           \n");<BR>        printf("\n\t\t               密  码:");<BR>        while((count&gt;=0)&amp;&amp;(pass[count++]=getch())!=13)    //密码输入 <BR>        {<BR>            if(pass[0]=='\b')<BR>            {<BR>                count=0;<BR>                continue;<BR>            }<BR>            else if(pass[count-1]=='\b')<BR>            {<BR>                printf("%c%c%c",'\b','\0','\b');<BR>                count-=2;<BR>            }<BR>            else<BR>            putchar('*');<BR>        }<BR>        pass[--count]='\0';<BR>        if(!strcmp(pass,PASSWORD))                          //开始验证 <BR>        {<BR>            system("cls");<BR>            printf("\n\n\n\n\n\n\n\n\n\t\t\t");<BR>            printf(" 欢 迎 登 陆 学 生 信 息 管 理 系 统 !");<BR>            start=time(NULL);<BR>            end=time(NULL);<BR>            while(end-start&lt;1)                              //延时1秒执行以下程序 <BR>            {<BR>                end=time(NULL);<BR>            }<BR>            system("cls");<BR>            free(pass);                                     //释放储存密码的内存 <BR>            return ;<BR>        }<BR>        free(pass);                                         //释放密码错误的那块内存 <BR>        pass=(char *)malloc(255*sizeof(char));              //重新分配储存密码内存 <BR>        system("cls");<BR>        printf("\a\n\n\n\n\n\n\n\n\t\t\t\t密 码 错 误 !");<BR>        getch();<BR>        system("cls");<BR>    }<BR>} </P>
<P>/***********************系统主菜单************************/<BR>int showmeun()<BR>{<BR>    int  in;<BR>    char ch;<BR>    <BR>    printf("\n\n\n\n");<BR>    printf("\t ╭────────────────────────────╮\n");<BR>    printf("\t ∣           学生个人信息管理系统v1.0测试版               ∣\n");<BR>    printf("\t |————————————————————————————|\n");<BR>    printf("\t | \t    1.  学生个人信息管理            |\n");<BR>    printf("\t |                            |\n");<BR>    printf("\t | \t    2. 学生个人成绩管理            |\n");<BR>    printf("\t |                            |\n");<BR>    printf("\t | \t    3. 关于本系统帮助             |\n");<BR>    printf("\t |                            |\n");<BR>    printf("\t | \t    4. 退 出 系 统             |\n");<BR>    printf("\t |                            |\n");       <BR>    printf("\t  ╰────────────────────────────╯\n");<BR>    printf("\t   请您正确选择:");<BR>    while(scanf("%d",&amp;in)!=1)<BR>    {<BR>        while((ch=getchar())!='\n')<BR>            putchar(ch);<BR>            return in;<BR>    }<BR>    fflush(stdin);<BR>    return in;<BR>}</P>
<P>/***************************************************************/<BR>//   个人信息管理系统目前只支持学生的个人资料登记<BR>//   不支持成绩的录入,如须录入学生的个人成绩,请<BR>//   使用“学生成绩管理系统,*必须要先在本系统登记<BR>//   之后才能正常使用成绩管理系统,否则可能会发生<BR>//   错误的提示 <BR>/***********************个人信息子菜单*************************/<BR>int submeun()<BR>{<BR>    int  in;<BR>    char ch;<BR>   <BR>    system("cls");<BR>    printf("\n\n\n");<BR>    printf("\t\t ————————————————————————\n");<BR>    printf("\t\t|      学生个人信息管理系统       |\n");<BR>    printf("\t\t|———————————————————————|\n");<BR>    printf("\t\t|       1.录入个人信息         |\n");<BR>    printf("\t\t|                       |\n");<BR>    printf("\t\t|       2.修改个人信息         |\n");<BR>    printf("\t\t|                       |\n");<BR>    printf("\t\t|       3.查询个人信息         |\n");<BR>    printf("\t\t|                       |\n");<BR>    printf("\t\t|       4.浏览所有信息         |\n");<BR>    printf("\t\t|                       |\n"); <BR>    printf("\t\t|       5.删除个人信息         |\n");<BR>    printf("\t\t|                       |\n");<BR>    printf("\t\t|       6.退出系统           |\n");<BR>    printf("\t\t ————————————————————————\n");<BR>    printf("\t\t 请您正确选择:");<BR>    while(scanf("%d",&amp;in)!=1)<BR>    {<BR>        while((ch=getchar())!='\n')<BR>            putchar(ch);<BR>            return 0;<BR>    }<BR>    fflush(stdin);<BR>    return in;<BR>}</P>
<P>/***************************修改个人信息子菜单************************/<BR>void modinfo(struct allstudentinfo *p_student)<BR>{<BR>    int  in;<BR>    char ch;<BR>    <BR>    do<BR>    {<BR>        system("cls");<BR>        printf("\n\n\n");<BR>        printf("\t\t ————————————————————————\n");<BR>        printf("\t\t|        个人信息修改管理       |\n");<BR>        printf("\t\t|———————————————————————|\n");<BR>        printf("\t\t|       1.修改用户姓名         |\n");<BR>        printf("\t\t|                       |\n");<BR>        printf("\t\t|       2.修改用户性别         |\n");<BR>        printf("\t\t|                       |\n");<BR>        printf("\t\t|       3.修改出生日期         |\n");<BR>        printf("\t\t|                       |\n");<BR>        printf("\t\t|       4.修改家庭住址         |\n");<BR>        printf("\t\t|                       |\n");<BR>        printf("\t\t|       5.修改联系电话         |\n");<BR>        printf("\t\t|                       |\n");<BR>        printf("\t\t|       6.修改邮证编码         |\n");<BR>        printf("\t\t|                       |\n");<BR>        printf("\t\t|       7.修改所在院校         |\n");<BR>        printf("\t\t|                       |\n");<BR>        printf("\t\t|       8.退出系统           |\n");<BR>        printf("\t\t ————————————————————————\n");<BR>        printf("\t\t 请您正确选择:");<BR>        while(scanf("%d",&amp;in)!=1)<BR>        {<BR>            while((ch=getchar())!='\n')<BR>                putchar(ch);<BR>            printf(" 没有此选项,请重新选择!");<BR>            getch();<BR>            system("cls");<BR>            return ;<BR>        }<BR>        fflush(stdin);<BR>        switch(in)<BR>        {<BR>            case 1 : mofname(p_student);<BR>                     break;<BR>            case 2 : mofsex(p_student);<BR>                     break;<BR>            case 3 : mofbirth(p_student);<BR>                     break;<BR>            case 4 : mofadddr(p_student);<BR>                     break;<BR>            case 5 : mofpoto(p_student);<BR>                     break;<BR>            case 6 : mofdak(p_student);<BR>                     break;<BR>            case 7 : mofschool(p_student);<BR>                     break;<BR>            case 8 : return ;<BR>              <BR>            default: printf("没有此选项,请重新选择!");<BR>                     break;<BR>        }<BR>    }while(1);<BR>}    </P>

gdzhan 发表于 2007-5-22 12:22

<P>/*************************个人信息录入*************************/<BR>void inputinfo(struct allstudentinfo *p_student)<BR>{<BR>    int  count;<BR>    char ch;<BR>    <BR>    system("cls");<BR>    if((infofile=fopen(filename,"a+b"))==NULL)<BR>    {<BR>        printf("不能打开文件,请确认磁盘已满或c:\\学生个人信息登记.dat文件没有损坏");<BR>        getch();<BR>        exit(1);<BR>    }<BR>    rewind(infofile);                                                   //定位文件头开始读取 <BR>    for(count=0;fread(&amp;p_student[count].student,sizeof(struct studentinfo),1,infofile)==1;count++)<BR>        continue; <BR>    printf("\n\n                    个人信息登记表\n");<BR>    printf("\n请正确填写以下信息(系统目前不能支持中文,请用英文或拼音\n"); <BR>    printf("---------------------------------------------------------\n\n");<BR>    printf("姓    名:");<BR>    while(count&lt;STUDENTMAX&amp;&amp;gets(p_student[count].student.name)!=NULL   //输入姓名 <BR>                          &amp;&amp;p_student[count].student.name[0]!='\0')<BR>    {<BR>        printf("\n性    别:");<BR>        gets(p_student[count].student.sex);                             //输入性别 <BR>        printf("\n出生日期:");<BR>        gets(p_student[count].student.birth);                           //输入出生日期<BR>        printf("\n家庭住址:");<BR>        gets(p_student[count].student.adddr);                           //输入家庭地址<BR>        printf("\n联系电话:");<BR>        gets(p_student[count].student.poto);                            //输入电话<BR>        printf("\n邮证编码:");<BR>        gets(p_student[count].student.dak);                             //输入邮证编码<BR>        printf("\n所属院校:");<BR>        gets(p_student[count].student.school);                          //输入所在院校<BR>                                                                        //将信息写入文件 <BR>        fwrite(&amp;p_student[count++].student,sizeof(struct studentinfo),1,infofile); <BR>        <BR>        printf("是否录入下一个学生信息(y/n)");<BR>        ch=getch(); <BR>        if(ch=='y'||ch=='Y')<BR>        {<BR>            system("cls");<BR>            printf("\n请输入下一个学生的个人信息\n");<BR>            printf("\n姓    名:"); <BR>            continue; <BR>        }                                                               //继续输入下一个学生信息 <BR>        else<BR>        {<BR>            printf("\n\n个人信息录入结束,返回!");<BR>            fclose(infofile);                                           //关闭文件 <BR>            getch();                                                    //返回子菜单<BR>            system("cls");<BR>            return ; <BR>        }<BR>    }<BR>    printf("输入有误,终止个人信息录信,返回!");<BR>    getch();<BR>    system("cls");<BR>    return ;                                                            //返回 <BR>}</P>
<P>/***********************查询个人信息****************************/<BR>void aboutinfo(struct allstudentinfo *p_student)<BR>{<BR>    int  i;<BR>    int  count;                                                     //学生计数器 <BR>    char ch;<BR>    char *temp=NULL;                                                //临时存储要查询的用户姓名 <BR>     <BR>    system("cls");<BR>    if((infofile=fopen(filename,"rb"))==NULL)<BR>    {<BR>        printf("不能打开文件,请确认磁盘已满或文件是否存在");<BR>        getch();<BR>        exit(1);<BR>    }<BR>    rewind(infofile);                                                //指向文件头<BR>    for(count=0;fread(&amp;p_student[count].student,sizeof(struct studentinfo),1,infofile)==1;count++)<BR>    {<BR>        continue;<BR>    }<BR>    fclose(infofile);                                                //关闭文件<BR>    if(!count)<BR>    {<BR>        printf("找不到个人数据,请确认已经成功录入或文件是否存在!");<BR>        getch();<BR>        system("cls");<BR>        return ;<BR>    }<BR>    temp=(char *)malloc(20*sizeof(char));                           //分配内存<BR>    printf("请输入要查询的学生姓名:"); <BR>    while(gets(temp)!=NULL&amp;&amp;temp[0]!='\0')<BR>    {<BR>        for(i=0;i&lt;count;i++)<BR>        {<BR>            if(!strcmp(temp,p_student[i].student.name))<BR>            {<BR>                system("cls");<BR>                printf("以下是你要查询%s的个人信息\n",p_student[i].student.name);<BR>                printf("\n                   个人信息查询表\n");<BR>                printf("-----------------------------------------------------------------\n");<BR>                printf("\n姓    名: %s\n",p_student[i].student.name);<BR>                printf("\n性    别: %s\n",p_student[i].student.sex);<BR>                printf("\n出生日期: %s\n",p_student[i].student.birth);<BR>                printf("\n家庭住址: %s\n",p_student[i].student.adddr);<BR>                printf("\n联系电话: %s\n",p_student[i].student.poto);<BR>                printf("\n邮证编码: %s\n",p_student[i].student.dak);<BR>                printf("\n所在院校: %s\n",p_student[i].student.school);<BR>                printf("-----------------------------------------------------------------\n");<BR>                break;<BR>            }<BR>        }<BR>        free(temp);                                                         //释放空间 <BR>        printf("\n查询下一个学生的个人信息(y/n)");<BR>        ch=getch();<BR>        if(ch=='y'||ch=='Y')<BR>        {<BR>            system("cls");<BR>            temp=(char *)malloc(20*sizeof(char));                                  //重新分配内存 <BR>            printf("请输入要查询的学生姓名:");<BR>            continue;<BR>        }<BR>        else<BR>        {<BR>            printf("\n查询结束,返回!");<BR>            getch();<BR>            system("cls");<BR>            return ;<BR>        }<BR>    }<BR>    free(temp);                                                             //释放已经分配的内存空间 <BR>    printf("\n输入有误,请按任意键返回子菜单!");<BR>    getch();<BR>    system("cls"); <BR>} </P>
<P>/****************************查询所有信息*******************************/<BR>void allabout(struct allstudentinfo *p_student)<BR>{<BR>    int i;<BR>    int count;<BR>    <BR>    system("cls");<BR>    if((infofile=fopen(filename,"rb"))==NULL)<BR>    {<BR>        printf("不能打开文件,请确认文件是否存在或是否损坏!");<BR>        getch();<BR>        exit(1);<BR>    }<BR>    rewind(infofile);                                                      //定位到文件头<BR>    for(count=0;fread(&amp;p_student[count].student,sizeof(struct studentinfo),1,infofile)==1;count++)<BR>    {<BR>        continue;<BR>    }<BR>    fclose(infofile);                                                      //读完后关闭文件<BR>    if(!count)<BR>    {<BR>        printf("不能读取数据,请确定文件是否存在或已经成功录入数据!");<BR>        getch();<BR>        system("cls");<BR>        return ;                                                           //反回重新操作 <BR>    }<BR>    printf("\n\t\t\t 学生个人信息查询表\n\n");<BR>    printf("\t 以下是本系统所查询到的所有学生个人信息,如果表中找不到数据\n");<BR>    printf(" 请确认是否已经成功录入本系统!\n");<BR>    printf("----------------------------------------");<BR>    printf("----------------------------------------\n");<BR>    for(i=0;i&lt;count;i++)<BR>    {<BR>        printf("您正在查看第[%d]个学生的个人信息\n",i+1); <BR>        printf("\n姓    名: %s\n",p_student[i].student.name);<BR>        printf("\n性    别: %s\n",p_student[i].student.sex);<BR>        printf("\n出生日期: %s\n",p_student[i].student.birth);<BR>        printf("\n家庭住址: %s\n",p_student[i].student.adddr);<BR>        printf("\n联系电话: %s\n",p_student[i].student.poto);<BR>        printf("\n邮证编码: %s\n",p_student[i].student.dak);<BR>        printf("\n所在院校: %s\n",p_student[i].student.school);<BR>        printf("------------------------------------"); <BR>        printf("------------------------------------\n");<BR>        printf("请按任意键继续查看信息........!");<BR>        getch();<BR>        system("cls");  <BR>    }<BR>    printf("\n查询结束..."); <BR>    printf("请按任意键返回!");<BR>    getch();<BR>    system("cls");<BR>    return ;<BR>} <BR>         <BR>/****************************删除个人信息*******************************/<BR>void delinfo(struct allstudentinfo *p_student)<BR>{<BR>    int  i;<BR>    int  count;<BR>    char ch;<BR>    char *temp=NULL;                                                        //初始化临时数组<BR>     <BR>    system("cls");                                                          //清屏 <BR>    if((infofile=fopen(filename,"rb"))==NULL)<BR>    {<BR>        printf("不能打开文件,请确认磁盘已满或文件是否存在");<BR>        getch();                                                            <BR>        exit(1);<BR>    }<BR>    rewind(infofile);                                                       //指向文件头  <BR>    for(count=0;fread(&amp;p_student[count].student,sizeof(struct studentinfo),1,infofile)==1;count++)<BR>    {<BR>        continue;<BR>    } <BR>    fclose(infofile);                                                       //关闭文件<BR>    if(!count)<BR>    {<BR>        printf("不能读取数据,请确认已经正确录入或数据是否存在");<BR>        getch();<BR>        return ;<BR>    }<BR>    temp=(char *)malloc(20*sizeof(char));                                   //分配内存<BR>    printf("请输入你要删除的学生姓名:");<BR>    while(gets(temp)!=NULL&amp;&amp;temp[0]!='\0')<BR>    {<BR>        for(i=0;i&lt;count;i++)<BR>        {<BR>            if(!strcmp(temp,p_student[i].student.name))<BR>            {<BR>                system("cls");<BR>                printf("\a\n\n\n\n\n\n\t\t 确定要删除%s的个人信息吗?(y/n)",p_student[i].student.name);<BR>                ch=getch();<BR>                if(ch=='n'||ch=='N')<BR>                {<BR>                    free(temp);<BR>                    system("cls");<BR>                    printf("\n\n\n\n\n\n\t\t     该操作已取消.请按任意键返回!");<BR>                    getch();<BR>                    system("cls");<BR>                    return ;<BR>                } <BR>                for(;i&lt;count;i++)<BR>                {<BR>                    p_student[i].student=p_student[i+1].student;<BR>                }<BR>                count--;                                                    //删除一个学生信息 <BR>                if((infofile=fopen(filename,"w+b"))==NULL)                  //重新打开文件更新 <BR>                {<BR>                    free(temp);<BR>                    printf("不能打开文件,请确认磁盘已满或文件是否存在");<BR>                    getch();<BR>                    exit(1);<BR>                }<BR>                for(i=0;i&lt;count;i++)<BR>                {                                                           //更新文件 <BR>                    if(fwrite(&amp;p_student[i].student,sizeof(struct studentinfo),1,infofile)!=1)<BR>                        break;<BR>                }<BR>                free(temp);                                                 //释放内存 <BR>                system("cls");                                                 <BR>                printf("\n\n\n\n\n\n\t\t        已成功删除该学生的个人信息.....\n");<BR>                printf("\n\t\t确定要删除下一个学生个人信息(y/n)");<BR>                ch=getch();<BR>                if(ch=='n'||ch=='N')<BR>                {<BR>                    fclose(infofile);<BR>                    system("cls");<BR>                    return ;<BR>                }<BR>                else<BR>                {<BR>                    <BR>                    system("cls");<BR>                    temp=(char *)malloc(20*sizeof(char));                   //重新分配内存以删除下一个信息 <BR>                    printf("请输入你想要删除的学生姓名:"); <BR>                    break; <BR>                }     <BR>            }   <BR>        }<BR>        printf("找不到%s的个人信息.",temp);<BR>        printf("请重新输入(y/n)");<BR>        ch=getch();<BR>        if(ch=='y'||ch=='Y')<BR>        {<BR>            free(temp);<BR>            temp=(char *)malloc(sizeof(char));                              //重新分配 <BR>            system("cls");<BR>            printf("请输入你要删除的学生姓名:"); <BR>            continue;<BR>        }<BR>        else<BR>        {<BR>            free(temp);<BR>            system("cls");<BR>            return ; <BR>        }<BR>    }<BR>    free(temp);                                                            //释放内存 <BR>    printf("输入有误,请按任意键返回子菜单,重新选择");<BR>    getch();<BR>    system("cls");<BR>} </P>
<P>/**********************修改用户姓名***************************/<BR>void mofname(struct allstudentinfo *p_student)<BR>{<BR>    char ch;<BR>    char *temp;<BR>    char *newtemp;                                                      <BR>    int  count;<BR>    int  i;<BR>     <BR>    system("cls");<BR>    count=datfile(p_student);                                             //处理文件                                                  <BR>    if(!count)<BR>    {<BR>        printf("读取数据失败,请确认已成功录入或文件数据是否损害!");<BR>        getch();<BR>        return ;<BR>    }<BR>    newtemp=(char *)malloc(20*sizeof(char));                              //分配内存 <BR>    temp=   (char *)malloc(20*sizeof(char));                              //分配内存<BR>    printf("请输入您要修改的学生姓名:");<BR>    while(gets(temp)!=NULL&amp;&amp;temp[0]!='\0')<BR>    {<BR>        for(i=0;i&lt;count;i++)<BR>        {<BR>            if(strcmp(temp,p_student[i].student.name))<BR>            {<BR>                continue;<BR>            }<BR>            else<BR>            {<BR>                printf("请您输入该学生的新姓名:");<BR>                gets(newtemp);<BR>                system("cls");<BR>                printf("\a\n\n\n\n\t\t\t确定要把姓名为%s的学生修改为%s码?(y/n)",temp,newtemp);<BR>                ch=getch();<BR>                if(ch=='y'||ch=='Y')<BR>                {<BR>                    strcpy(p_student[i].student.name,newtemp);            //修改姓名<BR>                    infofile=fopen(filename,"w+b");                       //重新写入文件<BR>                    for(i=0;i&lt;count;i++)<BR>                    {<BR>                        if(fwrite(&amp;p_student[i].student,sizeof(struct studentinfo),1,infofile)==1)<BR>                            continue;<BR>                        else<BR>                        {<BR>                            fclose(infofile);<BR>                            printf("修改失败,返回重新操作.....");<BR>                            getch();<BR>                            free(temp);<BR>                            free(newtemp);<BR>                            system("cls");<BR>                            return ;<BR>                        } <BR>                            <BR>                    }<BR>                    fclose(infofile);<BR>                    system("cls");<BR>                    printf("\n\n\n\n\t\t\t已成功把%s修改为%s返回!",temp,newtemp);<BR>                    getch();<BR>                    free(temp);<BR>                    free(newtemp); <BR>                    system("cls");<BR>                    return ;<BR>                }<BR>            }<BR>        }<BR>        printf("找不到%s的个人信息,返回重新操作!",temp);<BR>        free(temp);<BR>        free(newtemp);<BR>        getch();<BR>        system("cls");<BR>        return ; <BR>    } <BR>    printf("\n\n\n\n\t\t\t输入有误,请返回重新操作!");<BR>    getch();<BR>    free(temp);<BR>    free(newtemp);<BR>    system("cls");<BR>    return ;<BR>}<BR></P>

gdzhan 发表于 2007-5-22 12:23

<P>/************************修改个人性别*********************/<BR>void mofsex(struct allstudentinfo *p_student)<BR>{<BR>    char *tempname;                                                     //要修改的学生的名字<BR>    char *tempsex;                                                      //要修改的学生的性别<BR>    char ch;<BR>    int  count;<BR>    int  i;<BR>    <BR>    system("cls");<BR>    count=datfile(p_student);                                                         //处理文件<BR>    if(!count)<BR>    {<BR>        printf("读取数据失败,请确认已成功录入数据或文件是否损坏!");<BR>        getch();<BR>        return ;<BR>    }<BR>    <BR>    tempname=(char *)malloc(10*sizeof(char));                           //分配内存<BR>    tempsex=(char *)malloc(10*sizeof(char));                            //分配内存<BR>    printf("请输入要修改的学生姓名:");<BR>    while(gets(tempname)!=NULL&amp;&amp;tempname[0]!='\0')<BR>    {<BR>        for(i=0;i&lt;count;i++)<BR>        {<BR>            if(strcmp(tempname,p_student[i].student.name))<BR>                continue;<BR>            else<BR>            {<BR>                printf("请输入该学生的新性别:");<BR>                gets(tempsex);<BR>                system("cls");<BR>                printf("\a\n\n\n\n\t\t\t确定要修改该学生的性别吗?(y/n)");<BR>                ch=getch();<BR>                if(ch=='y'||ch=='Y')<BR>                {<BR>                    strcpy(p_student[i].student.sex,tempsex);<BR>                    infofile=fopen(filename,"w+b");<BR>                    for(i=0;i&lt;count;i++)<BR>                    {<BR>                        if(fwrite(&amp;p_student[i].student,sizeof(struct studentinfo),1,infofile)==1)<BR>                            continue;<BR>                        else<BR>                        {<BR>                            fclose(infofile);<BR>                            system("cls");<BR>                            printf("\n\n\n\n\t\t\t修改失败,请返回.....");<BR>                            getch();<BR>                            free(tempname);<BR>                            free(tempsex);<BR>                            system("cls");<BR>                            return ;<BR>                        }<BR>                    }<BR>                    fclose(infofile);<BR>                    system("cls");<BR>                    printf("\n\n\n\n\t\t\t已成功修改%s的性别,返回!",tempname);<BR>                    getch();<BR>                    free(tempname);<BR>                    free(tempsex);<BR>                    system("cls");<BR>                    return ; <BR>                }<BR>                printf("该操作已衩取消,返回.....");<BR>                free(tempname);<BR>                free(tempsex);<BR>                getch();<BR>                system("cls");<BR>                return ; <BR>            }<BR>        }<BR>        printf("找不到%s的个人信息,返回......",tempname);<BR>        free(tempname);<BR>        free(tempsex);<BR>        getch();<BR>        system("cls");<BR>        return ;<BR>    }<BR>    printf("输入有误,请返回重新输入!");<BR>    free(tempname);<BR>    free(tempsex);<BR>    getch();<BR>    system("cls");<BR>    return ;<BR>} </P>
<P>/**************************修改出生日期***************************/<BR>void mofbirth(struct allstudentinfo *p_student)<BR>{<BR>    char *tempname;<BR>    char *tempbirth;<BR>    char ch;<BR>    int  i,count;<BR>    <BR>    system("cls");<BR>    count=datfile(p_student);                                                         //处理文件<BR>    if(!count)<BR>    {<BR>        printf("读取数据失败,请确认已成功录入或数据是否损坏!");<BR>        getch();<BR>        return ;<BR>    }<BR>    <BR>    tempname=(char *)malloc(20*sizeof(char));<BR>    tempbirth=(char *)malloc(20*sizeof(char));                                         //分配内存<BR>    printf("请输入要修改的学生姓名:");<BR>    while(gets(tempname)!=NULL&amp;&amp;tempname[0]!='\0')<BR>    {<BR>        for(i=0;i&lt;count;i++)<BR>        {<BR>            if(strcmp(tempname,p_student[i].student.name))<BR>                continue;<BR>            else<BR>            {<BR>                printf("请重新输入该学生的出生日期:");<BR>                gets(tempbirth);<BR>                system("cls");<BR>                printf("\a\n\n\n\n\t\t\t确定要修改%s的出生日期吗?(y/n)",tempname);<BR>                ch=getch();<BR>                if(ch=='y'||ch=='Y')<BR>                {<BR>                    strcpy(p_student[i].student.birth,tempbirth);<BR>                    infofile=fopen(filename,"w+b");<BR>                    for(i=0;i&lt;count;i++)<BR>                    {<BR>                        if(fwrite(&amp;p_student[i].student,sizeof(struct studentinfo),1,infofile)==1)<BR>                            continue;<BR>                        else<BR>                        {<BR>                            fclose(infofile);<BR>                            free(tempname);<BR>                            free(tempbirth);<BR>                            system("cls");<BR>                            printf("\n\n\n\n\t\t\t修改失败,返回......");<BR>                            getch();<BR>                            system("cls");<BR>                            return ;<BR>                        }<BR>                    }<BR>                    fclose(infofile);<BR>                    system("cls");<BR>                    printf("\n\n\n\n\t\t\t成功修改%s的出生日期,返回!,",tempname);<BR>                    free(tempname);<BR>                    free(tempbirth);<BR>                    getch();<BR>                    system("cls");<BR>                    return ;<BR>                }<BR>                printf("\n\n\n\n\t\t\t该操作已被取消,返回!");<BR>                free(tempname);<BR>                free(tempbirth);<BR>                getch();<BR>                system("cls");<BR>                return ;<BR>            }<BR>        }<BR>        printf("\n\n\n\n\t\t\t找不到%s的个人信息,返回!",tempname);<BR>        free(tempname);<BR>        free(tempbirth);<BR>        getch();<BR>        system("cls");<BR>        return ;<BR>    }<BR>    printf("输入有误,请返回重新选择!");<BR>    free(tempname);<BR>    free(tempbirth);<BR>    getch();<BR>    system("cls");<BR>    return ;<BR>}</P>
<P>/***********************修改家庭住址*********************/<BR>void mofadddr(struct allstudentinfo *p_student)<BR>{<BR>    char *tempname;<BR>    char *tempadddr;<BR>    char ch;<BR>    int  i,count;<BR>    <BR>    system("cls");<BR>    count=datfile(p_student);                                                         //处理文件<BR>    if(!count)<BR>    {<BR>        printf("读取数据失败,请确认已成功录入或数据是否损坏!");<BR>        getch();<BR>        return ;<BR>    }<BR>    <BR>    tempname=(char *)malloc(20*sizeof(char));<BR>    tempadddr=(char *)malloc(20*sizeof(char));                                         //分配内存<BR>    printf("请输入要修改的学生姓名:");<BR>    while(gets(tempname)!=NULL&amp;&amp;tempname[0]!='\0')<BR>    {<BR>        for(i=0;i&lt;count;i++)<BR>        {<BR>            if(strcmp(tempname,p_student[i].student.name))<BR>                continue;<BR>            else<BR>            {<BR>                printf("请重新输入该学生的家庭住址:");<BR>                gets(tempadddr);<BR>                system("cls");<BR>                printf("\a\n\n\n\n\t\t\t确定要修改%s的家庭住址吗?(y/n)",tempname);<BR>                ch=getch();<BR>                if(ch=='y'||ch=='Y')<BR>                {<BR>                    strcpy(p_student[i].student.adddr,tempadddr);<BR>                    infofile=fopen(filename,"w+b");                                  //重新写入数据库 <BR>                    for(i=0;i&lt;count;i++)<BR>                    {<BR>                        if(fwrite(&amp;p_student[i].student,sizeof(struct studentinfo),1,infofile)==1)<BR>                            continue;<BR>                        else<BR>                        {<BR>                            fclose(infofile);<BR>                            free(tempname);<BR>                            free(tempadddr);<BR>                            system("cls");<BR>                            printf("\n\n\n\n\t\t\t修改失败,返回......!");<BR>                            getch();<BR>                            system("cls");<BR>                            return ;<BR>                        }<BR>                    }<BR>                    fclose(infofile);<BR>                    system("cls");<BR>                    printf("\n\n\n\n\t\t\t成功修改%s的家庭住址,返回......!,",tempname);<BR>                    free(tempname);<BR>                    free(tempadddr);<BR>                    getch();<BR>                    system("cls");<BR>                    return ;<BR>                }<BR>                printf("\n\n\n\n\t\t\t该操作已被取消,返回.......!");<BR>                free(tempname);<BR>                free(tempadddr);<BR>                getch();<BR>                system("cls");<BR>                return ;<BR>            }<BR>        }<BR>        printf("\n\n\n\n\t\t\t找不到%s的个人信息,返回.......!",tempname);<BR>        free(tempname);<BR>        free(tempadddr);<BR>        getch();<BR>        system("cls");<BR>        return ;<BR>    }<BR>    printf("输入有误,请返回重新选择.......!");<BR>    free(tempname);<BR>    free(tempadddr);<BR>    getch();<BR>    system("cls");<BR>    return ;<BR>}<BR>/*****************************修改联系电话********************************/<BR>void mofpoto(struct allstudentinfo *p_student)<BR>{<BR>    char *tempname;<BR>    char *temppoto;<BR>    char ch;<BR>    int  i,count;<BR>    <BR>    system("cls");<BR>    count=datfile(p_student);                                                         //处理文件<BR>    if(!count)<BR>    {<BR>        printf("读取数据失败,请确认已成功录入或数据是否损坏!");<BR>        getch();<BR>        system("cls");<BR>        return ;<BR>    }<BR>    <BR>    tempname=(char *)malloc(20*sizeof(char));<BR>    temppoto=(char *)malloc(20*sizeof(char));                                         //分配内存<BR>    printf("请输入要修改的学生姓名:");<BR>    while(gets(tempname)!=NULL&amp;&amp;tempname[0]!='\0')<BR>    {<BR>        for(i=0;i&lt;count;i++)<BR>        {<BR>            if(strcmp(tempname,p_student[i].student.name))<BR>                continue;<BR>            else<BR>            {<BR>                printf("请重新输入该学生的联系电话:");<BR>                gets(temppoto);<BR>                system("cls");<BR>                printf("\a\n\n\n\n\t\t\t确定要修改%s的联系电话吗?(y/n)",tempname);<BR>                ch=getch();<BR>                if(ch=='y'||ch=='Y')<BR>                {<BR>                    strcpy(p_student[i].student.poto,temppoto);<BR>                    infofile=fopen(filename,"w+b");<BR>                    for(i=0;i&lt;count;i++)<BR>                    {<BR>                        if(fwrite(&amp;p_student[i].student,sizeof(struct studentinfo),1,infofile)==1)<BR>                            continue;<BR>                        else<BR>                        {<BR>                            fclose(infofile);<BR>                            free(tempname);<BR>                            free(temppoto);<BR>                            system("cls");<BR>                            printf("\n\n\n\n\t\t\t修改失败,返回.......!");<BR>                            getch();<BR>                            system("cls");<BR>                            return ;<BR>                        }<BR>                    }<BR>                    fclose(infofile);<BR>                    system("cls");<BR>                    printf("\n\n\n\n\t\t\t成功修改%s的联系电话,返回.......!,",tempname);<BR>                    free(tempname);<BR>                    free(temppoto);<BR>                    getch();<BR>                    system("cls");<BR>                    return ;<BR>                }<BR>                printf("\n\n\n\n\t\t\t该操作已被取消,返回.......!");<BR>                free(tempname);<BR>                free(temppoto);<BR>                getch();<BR>                system("cls");<BR>                return ;<BR>            }<BR>        }<BR>        printf("\n\n\n\n\t\t\t找不到%s的个人信息,返回.......!",tempname);<BR>        free(tempname);<BR>        free(temppoto);<BR>        getch();<BR>        system("cls");<BR>        return ;<BR>    }<BR>    printf("输入有误,请返回重新选择.......!");<BR>    free(tempname);<BR>    free(temppoto);<BR>    getch();<BR>    system("cls");<BR>    return ;<BR>}<BR>/**************************修改邮证编码*************************/<BR>void mofdak(struct allstudentinfo *p_student)<BR>{<BR>    char *tempname;<BR>    char *tempdak;<BR>    char ch;<BR>    int  i,count;<BR>    <BR>    system("cls");<BR>    count=datfile(p_student);                                                         //处理文件 <BR>    if(!count)<BR>    {<BR>        printf("读取数据失败,请确认已成功录入或数据是否损坏!");<BR>        getch();<BR>        system("cls");<BR>        return ;<BR>    }<BR>    <BR>    tempname=(char *)malloc(20*sizeof(char));<BR>    tempdak =(char *)malloc(20*sizeof(char));                                         //分配内存<BR>    printf("请输入要修改的学生姓名:");<BR>    while(gets(tempname)!=NULL&amp;&amp;tempname[0]!='\0')<BR>    {<BR>        for(i=0;i&lt;count;i++)<BR>        {<BR>            if(strcmp(tempname,p_student[i].student.name))<BR>                continue;<BR>            else<BR>            {<BR>                printf("请重新输入该学生的邮证编码:");<BR>                gets(tempdak);<BR>                system("cls");<BR>                printf("\a\n\n\n\n\t\t\t确定要修改%s的邮证编码吗?(y/n)",tempname);<BR>                ch=getch();<BR>                if(ch=='y'||ch=='Y')<BR>                {<BR>                    strcpy(p_student[i].student.dak,tempdak);<BR>                    infofile=fopen(filename,"w+b");<BR>                    for(i=0;i&lt;count;i++)<BR>                    {<BR>                        if(fwrite(&amp;p_student[i].student,sizeof(struct studentinfo),1,infofile)==1)<BR>                            continue;<BR>                        else<BR>                        {<BR>                            fclose(infofile);<BR>                            free(tempname);<BR>                            free(tempdak);<BR>                            system("cls");<BR>                            printf("\n\n\n\n\t\t\t修改失败,返回.......!");<BR>                            getch();<BR>                            system("cls");<BR>                            return ;<BR>                        }<BR>                    }<BR>                    fclose(infofile);<BR>                    system("cls");<BR>                    printf("\n\n\n\n\t\t\t成功修改%s的邮证编码,返回.......!",tempname);<BR>                    free(tempname);<BR>                    free(tempdak);<BR>                    getch();<BR>                    system("cls");<BR>                    return ;<BR>                }<BR>                printf("\n\n\n\n\t\t\t该操作已取消,返回.......!");<BR>                free(tempname);<BR>                free(tempdak);<BR>                getch();<BR>                system("cls");<BR>                return ;<BR>            }<BR>        }<BR>        printf("\n\n\n\n\t\t\t找不到%s的个人信息,返回.......!",tempname);<BR>        free(tempname);<BR>        free(tempdak);<BR>        getch();<BR>        system("cls");<BR>        return ;<BR>    }<BR>    printf("输入有误,请返回重新选择.......!");<BR>    free(tempname);<BR>    free(tempdak);<BR>    getch();<BR>    system("cls");<BR>    return ;<BR>}<BR>/*************************修改所在院校******************************/<BR>void mofschool(struct allstudentinfo *p_student)<BR>{<BR>    char *tempname;<BR>    char *tempschool;<BR>    char ch;<BR>    int  i,count;<BR>    <BR>    system("cls");<BR>    count=datfile(p_student);                                                            //文件处理 <BR>    if(!count)<BR>    {<BR>        printf("读取数据失败,请确认已成功录入或数据是否损坏!");<BR>        getch();<BR>        system("cls");<BR>        return ;<BR>    }<BR>    <BR>    tempname=(char *)malloc(20*sizeof(char));<BR>    tempschool=(char *)malloc(20*sizeof(char));                                         //分配内存<BR>    printf("请输入要修改的学生姓名:");<BR>    while(gets(tempname)!=NULL&amp;&amp;tempname[0]!='\0')<BR>    {<BR>        for(i=0;i&lt;count;i++)<BR>        {<BR>            if(strcmp(tempname,p_student[i].student.name))<BR>                continue;<BR>            else<BR>            {<BR>                printf("请重新输入该学生的所在院校:");<BR>                gets(tempschool);<BR>                system("cls");<BR>                printf("\a\n\n\n\n\t\t\t确定要修改%s的所在院校吗?(y/n)",tempname);<BR>                ch=getch();<BR>                if(ch=='y'||ch=='Y')<BR>                {<BR>                    strcpy(p_student[i].student.school,tempschool);<BR>                    infofile=fopen(filename,"w+b");<BR>                    for(i=0;i&lt;count;i++)<BR>                    {<BR>                        if(fwrite(&amp;p_student[i].student,sizeof(struct studentinfo),1,infofile)==1)<BR>                            continue;<BR>                        else<BR>                        {<BR>                            fclose(infofile);<BR>                            free(tempname);<BR>                            free(tempschool);<BR>                            system("cls");<BR>                            printf("\n\n\n\n\t\t\t修改失败,返回.......!");<BR>                            getch();<BR>                            system("cls");<BR>                            return ;<BR>                        }<BR>                    }<BR>                    fclose(infofile);<BR>                    system("cls");<BR>                    printf("\n\n\n\n\t\t\t成功修改%s的所在院校,返回.......!",tempname);<BR>                    free(tempname);<BR>                    free(tempschool);<BR>                    getch();<BR>                    system("cls");<BR>                    return ;<BR>                }<BR>                printf("\n\n\n\n\t\t\t该操作已取消,返回.......!");<BR>                free(tempname);<BR>                free(tempschool);<BR>                getch();<BR>                system("cls");<BR>                return ;<BR>            }<BR>        }<BR>        printf("\n\n\n\n\t\t\t找不到%s的个人信息,返回.......!",tempname);<BR>        free(tempname);<BR>        free(tempschool);<BR>        getch();<BR>        system("cls");<BR>        return ;<BR>    }<BR>    printf("输入有误,请返回重新选择.......!");<BR>    free(tempname);<BR>    free(tempschool);<BR>    getch();<BR>    system("cls");<BR>    return ;<BR>}</P>
<P>/**************************修改个人信息的主要操作文件**************************/<BR>int datfile(struct allstudentinfo *p_student)<BR>{<BR>    int  count;<BR>    <BR>    system("cls");<BR>    if((infofile=fopen(filename,"rb"))==NULL)<BR>    {<BR>        printf("不能找开文件,请确认磁盘已满或文件是否存在!");<BR>        getch();<BR>        exit(1);<BR>    }<BR>    rewind(infofile);                                                //指向文件头读取数据                                                   <BR>    for(count=0;fread(&amp;p_student[count].student,sizeof(struct studentinfo),1,infofile)==1;count++)<BR>    {<BR>        continue;<BR>    }<BR>    fclose(infofile);<BR>    <BR>    return count;                                                     //返回读到的结构块数 <BR>} </P>

gdzhan 发表于 2007-5-22 12:25

<P>/***************************学生个人成绩管理***********************************/<BR>//       此子系统目前只支持学生的个人成绩的录入,修改,删除,查询等功能<BR>//       如没有在个人信息管理系统中登记个人信息的,可能会造成无法查询<BR>//       访问等错误的提示,请尽量在个人信息管理系统中成功登记了关于学生<BR>//       个人的相关信息之后再使用本系统。<BR>/******************************************************************************/<BR>void sorcmeun(struct allstudentinfo *p_student)<BR>{<BR>    int  in;<BR>    char ch;<BR>    <BR>    do<BR>    {<BR>        system("cls");<BR>        printf("\n\n\n\n");<BR>        printf("\t\t  —————————————————————\n");<BR>        printf("\t\t |           学生个人成绩管理             |\n");<BR>        printf("\t\t |————————————————————|\n");<BR>        printf("\t\t |     1.  录入学生个人成绩      |\n");<BR>        printf("\t\t |                    |\n");<BR>        printf("\t\t |    2. 修改学生个人成绩      |\n");<BR>        printf("\t\t |                    |\n");<BR>        printf("\t\t |    3. 查询学生个人成绩      |\n");<BR>        printf("\t\t |                    |\n");<BR>        printf("\t\t |    4. 浏览所有学生的成绩     |\n");<BR>        printf("\t\t |                    |\n");<BR>        printf("\t\t |    5. 删除学生成绩        |\n");<BR>        printf("\t\t |                    |\n");<BR>        printf("\t\t |    6. 退出成绩管理系统      |\n");<BR>        printf("\t\t |————————————————————|\n");<BR>        printf("\t\t  请您正确选择: ");<BR>        if(!(scanf("%d",&amp;in)==1))<BR>        {<BR>            while((ch=getchar())!='\n')<BR>                putchar(ch);<BR>            printf(" 没有此选项,请正确选择!");<BR>            getch();<BR>            continue;<BR>        }<BR>        fflush(stdin);<BR>        switch(in)<BR>        {<BR>            case 1 : inputsorc(p_student);                                  //录入成绩<BR>                     break;<BR>            case 2 : mofsorc  (p_student);                                  //修改成绩<BR>                     break;<BR>            case 3 : seasorc  (p_student);                                  //查询个人成绩<BR>                     break;<BR>            case 4 : seaallsorc(p_student);                                 //浏览所有学生成绩<BR>                     break;<BR>            case 5 : delsorc  (p_student);                                  //删除学生成绩<BR>                     break;<BR>            case 6 : return ;                                               //返回<BR>            <BR>            default: printf("没有此选项,请正确选择!");<BR>                     break;<BR>        }<BR>    }while(1);<BR>}</P>
<P>/************************个人成绩录入*************************/<BR>void inputsorc(struct allstudentinfo *p_student)<BR>{<BR>    int  i,count,countinfo;<BR>    char *tempname,ch;<BR>    <BR>    system("cls");<BR>    if((sorcfile=fopen(filename1,"a+b"))==NULL)                              //打开或新建成绩数据文件 <BR>    {<BR>        printf("不能找开文件,请确认磁盘已满或文件是否存在");<BR>        getch();<BR>        exit(1);<BR>    }<BR>    rewind(sorcfile);                                                       //定位文件头 <BR>    for(count=0;fread(&amp;p_student[count].student1,sizeof(struct studentsorc),1,sorcfile)==1;count++)<BR>    {<BR>        continue;<BR>    }<BR>    tempname=(char *)malloc(20*sizeof(char));                               //分配内存 <BR>    printf("请输入第%d学生的姓名:",count+1);<BR>    while(count&lt;STUDENTMAX&amp;&amp;gets(tempname)!=NULL&amp;&amp;tempname[0]!='\0')<BR>    {<BR>        strcpy(p_student[count].student1.name,tempname);      <BR>        printf("请输入该学生的学号:");<BR>        scanf("%d",&amp;p_student[count].student1.ID);                         //输入学号<BR>        fflush(stdin);                                                     //刷新绶冲<BR>        printf("请输入该学生的6科成绩\n");<BR>        printf("——————————————————————————————\n");<BR>        printf("\n语文: ");<BR>        scanf("%f",&amp;p_student[count].stude