首页 > 其他 > 详细

19.05.02--读写文件

时间:2019-05-02 12:53:34      阅读:112      评论:0      收藏:0      [点我收藏+]
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<time.h>
int main()
{
 int j=0,x,a[1024];
 char rand_num[5];
 FILE *stream=fopen("1.txt","w");
 srand((unsigned)time(NULL));
 for(int i=0;i<500;i++)
 {
  x=rand()%100;
  sprintf(rand_num,"%d\n",x);
  fputs(rand_num,stream);
 }
 fclose(stream);
 stream=fopen("1.txt","r");
 i=0;
 while(!feof(stream))fscanf(stream,"%d",&a[i++]);
 for(i=0;i<500;i++)printf("%d\t",a[i]);
 printf("\n");
 fclose(stream);
 return 0;
}

19.05.02--读写文件

原文:https://www.cnblogs.com/redyellowblue/p/10801821.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!