2023年5月4日

倒序输出文件中的文本(英文文本,Linux环境)

摘要: /*倒序显示文本内容: linux环境*/ #include<stdio.h> #include<stdlib.h> #define SLEN 81 int main(void) { char *file = "hello.txt"; char ch; FILE *fp; long count, l 阅读全文

posted @ 2023-05-04 20:02 david_helloworld 阅读(42) 评论(0) 推荐(0)

C语言文件读写错误检测

摘要: if (ferror(f))//文件读取中发生错误,检查刚刚是否发生错误,如果错误发生就退出 { printf("Error: there is an error in file reading!\n"); exit(1); } 阅读全文

posted @ 2023-05-04 19:24 david_helloworld 阅读(49) 评论(0) 推荐(0)

兼容 windows 和 Linux 的fgets文件读取方式(判断文件尾)

摘要: /*检测文件尾范例 使用fgets读取文件 */ /*范例: 检测文件尾,windows和linux,unix平台兼容版本*/ #include<stdio.h> #include<stdlib.h> #define BUFSIZE 100 int main(void) { FILE *f; cha 阅读全文

posted @ 2023-05-04 19:12 david_helloworld 阅读(48) 评论(0) 推荐(0)

用二进制I/O进行随机访问

摘要: /* randbin.c 用二进制I/O进行随机访问 */ #include<stdio.h> #include<stdlib.h> #define ARSIZE 1000//数组元素个数是 ARSIZE, 字符常量 int main(int argc, char *argv[]) { double 阅读全文

posted @ 2023-05-04 15:58 david_helloworld 阅读(19) 评论(0) 推荐(0)

导航

点击右上角即可分享
微信分享提示