| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 688 人关注过本帖
标题:2级C求解
取消只看楼主 加入收藏
时光追不回1
Rank: 1
等 级:新手上路
帖 子:7
专家分:0
注 册:2016-4-29
结帖率:0
收藏
 问题点数:0 回复次数:0 
2级C求解
#include<stdio.h>
#define N 5
typedef struct srudent
{
    long sno;
    char name[10];
    float score[3];
   
   
}STU;
void fun(char *filename,STU n)
{
    FILE *fp;
    fp =fopen(filename,"rb+");
    fseek (fp, -(long)sizeof(STU),SEEK_END);
    fwrite(&n,sizeof(STU),1,fp);
    fclose(fp);
   
}
main()
{
    STU t[N]={10001,"MaChao",91,92,77},
             {10002,"CaoKai",75,60,88},
             {10003,"LiSi",85,70,78},
             {10005,"ZhangSan",95,80,88};
    STU n ={10006,"ZhaoSi",55,70,68},ss[N];
    int i,j; FILE *fp;
    fp= fopen("student.dat","wb");
    fwrite(t,sizeof(STU),N,fp);
    fclose(fp);
    fp = fopen("student.dat","rb");
    fread(ss,sizeof(STU),N,fp);
    fclose(fp);
    printf("\nThe original data :\n\n");
    for (j =0;j<N;j++);
    {
        printf("%6.2F",ss[j].score[i]);
        printf("\n")
    }
    fun (student.dat,n);
    printf("\n Tne date after modifing :\n\n");
    fp =fopen("stundent.dat","rb");
    fread(ss,sizeof(STU),N,fp);
    fclose(fp);
    for(j=0;j<N;j++)
    {
        printf("\nNo: % ld Name: % -8sScores:",ss[j].sno,ss[j]name);
        for (i=0;i<3;i++)
        printf("6.2f",ss[j].score[i]);
        printf("\n");
        
    }         
}
这里怎么运行不了STU t[N]={10001,"MaChao",91,92,77},
             {10002,"CaoKai",75,60,88},
图片附件: 游客没有浏览图片的权限,请 登录注册
搜索更多相关主题的帖子: include 
2016-08-06 14:42
快速回复:2级C求解
数据加载中...
 
   



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

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