| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 622 人关注过本帖
标题:实在是看不明白。。。。。。。
取消只看楼主 加入收藏
joanneken
Rank: 1
等 级:新手上路
帖 子:5
专家分:0
注 册:2008-9-11
收藏
 问题点数:0 回复次数:2 
实在是看不明白。。。。。。。
这个是老师给我发的一个代码  但是我实在是看不明白。哪位大哥来帮忙看下呗 解释下是啥意思~

#include  "common.h"
void main()
{
    FILE *fp = NULL;
    struct student TmpS;
    char DataFile[40] = "";
    int count = 1; /*Circular variable is to control maximum of input data.*/
    printf("\nplease input the file name to store data,end with enter.");
    printf("\n(Notice:Name of file can't exceed 8 characters,\nsuffix can't exceed 3 characters)\n");
    scanf("%s",DataFile);
    while(DataFile[0] == ('\0'))
    {
        printf("\nplease input new file name to store data,end with enter.");
        printf("\n(Notice:Name of file can't exceed 8 characters,\nsuffix can't exceed 3 characters,\npart of exceed will be discarded.)\n");
        scanf("%s",DataFile);
    }

    fp = fopen(DataFile,"wb+");
    if (fp == NULL)
    {
        printf("\n Open file %s fail!End with any key.\n",DataFile);
        return;
    }

    printf("Please input student infomation.\n0 means end.\n");
    printf("(Notice:Number is not exceed 9 figures;Name is not exceed 20 characters;Range of grade:0~100)\n");
    while(count <= SIZE) /* It's to control recorders less then maximum of stated input data. */
    {
        printf("\n Student number:");
        scanf("%d",&TmpS.number);
        if (TmpS.number == 0 )
            break;
        
        printf("Student name:");
        scanf("%s",TmpS.name);
        
        printf("Englishscore:");
        scanf("%d",&TmpS.score);
        
        printf("\n");
        if(fwrite(&TmpS,sizeof(LENGTH),1,fp)!=1)
        {
            printf("\nwrite file %s fail!End with any key\n",DataFile);
            return;
        }
        count++;
    }

    if (count>SIZE)
        printf("\nsorry,number of data can not exceed %d\n",SIZE);
    fclose(fp);
   
    /*====Showing content of file on screen.====*/
    printf("The data has stored successfully in file %s.\n",DataFile);
    printf("Content as follow:\n");
   
    fp=fopen(DataFile,"rb");
    if (fp == NULL)
    {
        printf("\nOpen file%sfail!End with any key \n",DataFile);
        return;
    }
    while(fread(&TmpS,sizeof(LENGTH),1,fp) != (int)NULL)
    {
        printf("\n%9ld\t%s\t%8d\n",TmpS.number,TmpS.name,TmpS.score);
    }
    fclose(fp);

}
搜索更多相关主题的帖子: control include exceed store count 
2008-09-11 14:34
joanneken
Rank: 1
等 级:新手上路
帖 子:5
专家分:0
注 册:2008-9-11
收藏
得分:0 
因为实在是看不明白。。不知道要怎么问。。。才好~
2008-09-11 15:55
joanneken
Rank: 1
等 级:新手上路
帖 子:5
专家分:0
注 册:2008-9-11
收藏
得分:0 
谢谢楼上的 回答
但是可以告诉我下 哪的错误比较严重啊  具体说1~2个就行   谢谢了~
2008-09-12 13:38
快速回复:实在是看不明白。。。。。。。
数据加载中...
 
   



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

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