博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
19.05.02--读写文件
阅读量:6873 次
发布时间:2019-06-26

本文共 513 字,大约阅读时间需要 1 分钟。

#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;
}

转载于:https://www.cnblogs.com/redyellowblue/p/10801821.html

你可能感兴趣的文章
Windows Server 2008 FTP用户目录隔离模式
查看>>
python实现linux下指定目录下文件中的单词个数统计
查看>>
Android源代码下载编译
查看>>
jsp---语句对象Statement
查看>>
RESTful API
查看>>
前端UI框架总结
查看>>
Atom 初识
查看>>
每日英语:Poor Chinese Schools Tell Students: Bring Your Own Desks
查看>>
用c++和python写GUI程序(python嵌入方式)
查看>>
2013年8月3日第31周六
查看>>
如何处理数组越界而不会让程序崩溃?
查看>>
请保护我们的地球
查看>>
翻转字符串
查看>>
Ext.MessageBox消息框
查看>>
电脑知识:修电脑(转)
查看>>
jQuery 1.7.2 animate功能跨浏览器Bug修补
查看>>
HTML <map>标签的使用
查看>>
freebsd用法汇总[zz]
查看>>
041 SparkSql的回顾与复习
查看>>
web前端自动化测试利器puppeteer介绍
查看>>