标题:求助 关于文件
取消只看楼主
田衰衰
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2008-5-1
 问题点数:0 回复次数:0 
求助 关于文件
#include "stdlib.h"
#include "stdio.h"
#define SIZE 5
main()
{
  struct student_type
     {
       char name[10];
       int num;
       int age;
       float score;
     }stud[SIZE];
     FILE *fp;
     int i;
     if((fp=fopen("stulist","wb"))==NULL)
       {printf("can not open file.\n");exit(0);}
     for(i=0;i<SIZE;i++)
        {scanf("%s%d%d%f",stud[i].name,&stud[i].num,&stud[i].age,&stud[i].score);
         if(fwrite(&stud[i],sizeof(struct student_type),1,fp)!=1)
         {printf("file write error!\n");break;}
        }
     fclose(fp);


}
搜索更多相关主题的帖子: stud int 文件 score 
2008-05-26 14:50



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-215995-1-1.html




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

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