| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 899 人关注过本帖
标题:求解答,fopen引用以后显示不出来
只看楼主 加入收藏
心思烟火
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2021-3-14
收藏
 问题点数:0 回复次数:0 
求解答,fopen引用以后显示不出来
#ifndef _STUDENT_H_
#define _STUDENT_H_
#define LEN sizeof(struct student)
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <malloc.h>
#include <math.h>
#include <windows.h>
#include <conio.h>

struct student
{
    char name[100];
    long num;
    char grade[100];
    char Class[100];
    char sex[100];
    char nation[100];
    char position[100];
    float s1;
    float s2;
    float s3;
    float s4;
    float s5;
    float s6;
    struct student *next;
};

void color(short x);
struct student *space();
void print(struct student *head);

#endif // _STUDENT_H

void color(short x)
{
    if(x>=0&&x<=15)SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),x);
    else   SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE),7);
}

int main()
{
    printf("\t\t\t     欢迎您使用大学生成绩管理系统,请按回车键进行您想要的操作");
    getchar();
    printf("\n");printf("\n");printf("\n");
    color(6);printf("\t\t\t◤※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※◥\n");
    printf("\n");printf("\n");
    color(3);printf("\t\t\t←←←                 大学生成绩管理系统               →→→\n");
    printf("\n");printf("\n");
    color(6);printf("\t\t\t←←←                    1.数据查询                    →→→\n");
    color(2);printf("\t\t\t←←←                    2.数据浏览                    →→→\n");
    color(3);printf("\t\t\t←←←                    3.数据维护                    →→→\n");
    color(14);printf("\t\t\t←←←                    4.信息输入                    →→→\n");
    color(15);printf("\t\t\t←←←                    5.数据统计                    →→→\n");
    color(5);printf("\t\t\t←←←                    6.  帮助                      →→→\n");
    color(7);printf("\t\t\t←←←                    7.  退出                      →→→\n");
    printf("\n");printf("\n");
    color(10);printf("\t\t\t\tThis system is powered by 人智2001葛琪琛&&人智2001缪天雨\n");
    color(6);printf("\t\t\t◣※※※※※※※※※※※※※※※※※※※※※※※※※※※※※※◢\n");
    printf("\n");printf("\n");
    color(8);printf("请输入您要进行的操作前的序号");
    int a;
    struct student *head;
    scanf("%d",&a);
    switch(a)
    {
    case 1:
    {  int num1;
       printf("请选择查询方式\n");
       printf("1.单一查询\n2.组合查询\n3.模糊查询\n");
       scanf("%d",&num1);
       /*switch(num1)
       {
           case 1:
           {
               printf("1.按姓名查询学生信息\n2.按学号查询学生信息\n");//可以添加
               scanf("%d",&num2);
               switch(num2)
               {
                   case 1:
                   {
                       inquire1();//姓名查询函数
                   }
                   case 2:
                   {
                       inquire2();//学号查询函数
                   }
               }
            break;
           }
           case 2:
           {
               printf("1.按姓名和课程查询成绩\n2.按学号和课程查询成绩");//可以添加
               scanf("%d",&num3);
               switch(num3)
               {
                   case 1:
                   {
                       inquire3();//函数
                   }
                   case 2:
                   {
                       inquire4();//函数
                   }
               }
            break;
           }
           case 3:
           {
               printf("1.按姓名查询学生信息\n2.按地址查询学生信息\n");//可以添加
               scanf("%d",&num4);
               switch(num4)
               {
                   case 1:
                   {
                       inquire5();//函数
                   }
                   case 2:
                   {
                       inquire6();//函数
                   }
               }

            break;
           }
       }*/
    }
    case 2:
        {

        system("cls");
        printf("\t\t\t\t\t此时您进行的是数据浏览\n");
        printf("\t\t\t********************学生成绩信息表********************\n");
        printf("姓名\t学号\t年级\t班级\t性别\t民族\t省市\t线代\t高数\t英语\t思修\t心理健康\t大物\n");
        print(head);
        printf("\n按任意键回到菜单\n");
        getch();
        system("cls");
        break;
        }
    case 3:{printf("此时您进行的是数据维护\n");break;}
    case 4:{printf("此时您进行的是信息输入\n");break;}
    case 5:{printf("此时您进行的是数据统计\n");break;}
    case 6:{printf("请问与什么可以帮到您的吗?\n");printf("以下是询问次数较多的问题\n");break;}
    case 7:{printf("感谢您的使用,祝您万事顺利,再见");break;}
    default:break;
    }
    return 0;
}


struct student *space()
{
    char b[100];
    FILE *fp=fopen("C:\\Users\\HP\\Desktop\\c语言程序设计","rt");
    struct student *head,*p,*q;
    p=q=(struct student *)malloc(LEN);
    if((fp=fopen("C:\\Users\\HP\\Desktop\\c语言程序设计","rt"))==NULL)
    {
        printf("can't open file correctly\n");
        exit(0);
    }
    fgets(b,100,fp);
    head=p;
    fscanf(fp,"%s%ld%s%s%s%f%f%f%f%f%f\n",p->name,&q->num,&p->sex,&p->nation,&p->position,&p->s1,&p->s2,&p->s3,&p->s4,&p->s5,&p->s6);

    while(!feof(fp))
        {
            q=(struct student *)malloc(LEN);
            fscanf(fp,"%s%ld%s%s%s%f%f%f%f%f%f\n",p->name,&q->num,&p->sex,&p->nation,&p->position,&p->s1,&p->s2,&p->s3,&p->s4,&p->s5,&p->s6);

            p->next=q;
            p=q;
        }
    p->next=NULL;
    fclose(fp);
    return head;
}

void print(struct student *head)
{
    struct student *p;
    p=head;
    while(p)
    {
        printf("%s%ld%s%s%s%.2f%.2f%.2f%.2f%.2f%.2f\n",p->name,p->num,p->sex,p->nation,p->position,p->s1,p->s2,p->s3,p->s4,p->s5,p->s6);
        p=p->next;
    }
}
搜索更多相关主题的帖子: struct printf color case 查询 
2021-03-14 10:28
快速回复:求解答,fopen引用以后显示不出来
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.025310 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved