文件函数的小结(1)
2014-04-15 20:40
267 查看
文件的读写
一.字符读写函数( fgetc, fputc )读:字符变量= fgetc(
文件指针);
写:写入字符或EOF = fputc(字符量,
文件指针);
二.字符串读写函数(fgets, fputs)
字符串地址 = fgets(字符数组名,
n, 文件指针);
非负整数= fputs(字符串,
文件指针);
三.数据块读写函数(fread,fwrite)
实际读取的元素个数=fread(butter, size, count, fp);
实际写入的元素个数= fwrite(butter, size, count, fp);
(1)buffer:是一个指针,对fread来说,它是读入数据的存放地址。对fwrite来说,是要输出数据的地址。
(2)size:要读写的字节数;
(3)count: 要进行读写多少个size字节的数据项;
(4)fp:文件型指针。
size_t fread ( void * ptr, size_t size, size_t count, FILE * stream );
Reads an array of count elements, each one with a size of size bytes, from the stream and stores them in the block of memory specified by ptr. The position indicator of the stream is advanced by the total amount of bytes read.The total amount of bytes read if successful is (size*count).size_t is an unsigned integral type.
四.格式化读写函数(fscanf,fprintf)
成功读入的参数的个数= fscanf ( fp , "%s %d %lf" , a , &b , &c);
返回输出字符数= fprintf(fp, “%d %c”, j, ch);
相关文章推荐
- Java设计模式之从[魔兽争霸、星际争霸、DOTA编队]分析迭代器(Iterator)模式
- auto_load
- WebGL入门教程第1篇——六色立方
- 心中的顽石。
- jquery小知识
- 为什么新手开车起步总是熄火
- 科目三-变更车道,直线行驶和超车的考试标准
- hdu 3496 Watch The Movie (二维背包)
- Win7+Editplus配置Python的开发环境
- 暗黑破坏神
- POJ1004
- 内存地址巧分析
- iOS- iPhone App 如何运营?
- Cracking The Coding Interview4.3
- nyoj 103 A+B Problem II
- 科目三考试里面的会车,调头,靠边停车通过标准
- 掌握新手学车技巧对于新手来说是非常重要的
- 新手必须掌握的学车技巧-上坡起步
- wikioi天梯之1098 均分纸牌 贪心
- java 访问权限