fseek Linux 编程手册
来源:互联网 发布:医美缩小毛孔知乎 编辑:程序博客网 时间:2024/06/14 10:38
#include <stdio.h>#include <stdlib.h> int main(void){ /* Prepare an array of f-p values. */ #define SIZE 5 double A[SIZE] = {1.,2.,3.,4.,5.}; /* Write array to a file. */ FILE * fp = fopen("test.bin", "wb"); fwrite(A,sizeof(double),SIZE,fp); fclose (fp); /* Read the f-p values into array B. */ double B[SIZE]; fp = fopen("test.bin","rb"); /* Set the file position indicator in front of third f-p value. */ if (fseek(fp,sizeof(double)*3L,SEEK_SET) != 0) { if (ferror(fp)) { perror("fseek()"); fprintf(stderr,"fseek() failed in file %s at line # %d\n", __FILE__,__LINE__-5); exit(EXIT_FAILURE); } } int ret_code = fread(B,sizeof(double),1,fp); /* read one f-p value */ printf("%.1f\n", B[0]); /* print one f-p value */ fclose(fp); return EXIT_SUCCESS;}
结果输出
4.0
fseek参数解释
stream-file stream to modify 将要改变的文件流offset-number of characters to shift the position relative to origin 相对于origin 位置偏移的字符个数origin-position to whichoffset
is added. It can have one of the following values: SEEK_SET, SEEK_CUR, SEEK_END位置信息:开始,当前以及结尾阅读全文
0 0
- fseek Linux 编程手册
- Linux编程手册
- Linux编程手册
- Linux 函数--fseek
- Linux 函数--fseek
- linux系统编程手册 文件系统
- Linux编程手册学习笔记
- 文件编程:定位fseek()函数
- fseek(3) - Linux man page
- fseek
- fseek()
- fseek
- fseek
- fseek
- fseek()
- fseek()
- fseek
- fseek
- 2017特许加盟展武汉站会刊(参展商名录)
- FTP主动被动模式(PORT PASV)
- [LeetCode] Add Two Numbers
- java自制链式调用
- MongoDB总结
- fseek Linux 编程手册
- Gaussian Filter from DFT
- 生成二维码
- AP 音频测试
- 配置OpenCV3.2.0教程
- TensorFLow 不同大小图片的TFrecords存取
- js如何获取table中动态生成的数据
- CString/string 区别及其转化
- 【Android】ViewPager探索