读写文件(File)
来源:互联网 发布:方大同 桃花运 知乎 编辑:程序博客网 时间:2024/06/10 19:03
#include "stdafx.h"#include <iostream>#include <string>using namespace std;int main () {FILE * pFile;long lSize;char *buffer;size_t result;char *cPath = "G:\\timg.jpg";pFile = fopen ( cPath , "rb" );if (pFile==NULL) {fputs("File error",stderr); exit (1);}//获取文件的大小fseek (pFile , 0 , SEEK_END);lSize = ftell (pFile);rewind (pFile);//复位//为buffer分配内存buffer = (char*) malloc (sizeof(char)*lSize);if (buffer == NULL) {fputs ("Memory error",stderr); exit (2);}// copy the file into the buffer:long defSize = 1024;long i = 0;int j = 1;char *cNewPath = "F:\\timg.jpg";FILE *pNewFile;pNewFile = fopen (cNewPath,"a+b");while (i > -1){cout<<i<<" : "<<fread (buffer, 1, defSize, pFile)<<endl;fwrite (buffer, sizeof(char), defSize, pNewFile);//fseek (pFile, 0, SEEK_CUR);i = lSize - defSize*j;j++;}// terminatefclose (pFile);free (buffer);return 0;}
阅读全文
0 0
- 读写文件(File)
- File文件读写(转)
- FILE*读写文件
- java File 文件读写
- file文件的读写
- FILE文件读写注意事项
- 第十天 file文件读写
- Java文件读写操作(file I/O)
- Python文件(File)及读写操作及生成器yield
- 好简单的file文件的读写
- VC 读写txt文件——FILE *
- VC 读写txt文件——FILE *
- Java中的File类 读写复制文件
- File编程:读写文件简易实例
- android File文件的读写操作
- java中的File文件读写操作
- java中的File文件读写操作
- File类文件读写函数案例
- HDU 6166 集合间求最短路
- DotNetCore跨平台~EFCore数据上下文的创建方式
- 作为游戏测试需要具备的技能
- windows操作系统,可用内存占用很多(即可用内存越来越少),系统为什么会卡?表现为电脑反应很慢,不应该是内存只要不占满,电脑就不卡吗?
- mysql数据命令(登录与导入导出)
- 读写文件(File)
- 使窗口具备拖动到边界自动最大化/还原的特性
- java常见异常
- 关于“深蓝”
- easyUI入门--2
- 抽象和接口---随记
- 我的第一篇
- UVA11300:Spreading the Wealth
- SpringMVC文件(图片)上传,下载