基本文件输入输出
2019-03-15 10:59
58 查看
#include "stdafx.h" #include <stdio.h> int main() { FILE *fin,*fout; fin = fopen("data.in", "rb"); fout = fopen("data.out", "wb"); int x, n = 0, min, max, s = 0; fscanf(fin, "%d", &x); min = max = x; s += x; n++; while (fscanf(fin, "%d", &x) == 1) { if (x < min) min = x; if (x > max) max = x; n++; } fprintf(fout, "%d %d %.3f\n", min, max, (double)s / n); fclose(fin); fclose(fout); return 0; }
声明两个变量fin和fout,使输入流源和输出流目标定向为文件,其余用法和scanf,printf类似
相关文章推荐
- 文件输入输出流->带缓冲的输入输出流(过滤流)->基本数据的输入输出流 链接 增强了文件输入输出流的功能
- 文件输入输出流->带缓冲的输入输出流(过滤流)->基本数据的输入输出流 链接 增强了文件输入输出流的功能
- android中基本文件输入输出流的使用(代码)
- 头文件和基本输入输出语句
- numpy教程:基本输入输出和文件输入输出Input and output
- C语言基本教程 第12课:文件输入输出(IO)
- 黑马程序员--Java基础学习之IO流之字节流、字符流、读取写入文件、Copy文件、键盘输入输出、流操作的基本规律
- C++ Primer Plus学习笔记 第六章 cctype字符函数库 switch语句 continue和break语句 基本文件输入输出
- 文件输入输出流->带缓冲的输入输出流(过滤流)->基本数据的输入输出流 链接 增强了文件输入输出流的功能
- FileUtils 基本文件操作
- python-文件的基本操作
- ASP.NET上传文件的三种基本方法
- 输入输出流(IO)—文件字节流(FileInputStream & FileOutputStream)的基本操作及运用
- web.xml文件的作用及基本配置
- CentOS装机必备-基本设置以及缺失文件
- Python(2)(基本输入输出语句)
- Linux文件基本操作
- 1.1、class文件基本组织结构
- Hadoop基本文件命令
- iOS开发中文件的上传和下载功能的基本实现-备用