文件操作
2015-07-21 16:16
246 查看
一:在C语言中关于文件的操作
int arr[5];
FILE *p_file = fopen("a.txt","ab");
if (p_file == -1) perror("open"),exit(-1);
fread(arr,sizeof(int),5,p_file);
fclose(p_file);
二:在UNIX中关于文件的操作
int fd = open("a.txt",O_RDONLY|O_CREAT|O_TUEN,0666);
if (fd == -1)perror("open"),exit(-1);
write(fd,"hello",5);
close(fd);
int buff[10];
int res = read(fd,buff,sizeof(buff));
printf("res=%d,buff=%s\r\n",res,buff); //res = 5,buff = hello;
int arr[5];
FILE *p_file = fopen("a.txt","ab");
if (p_file == -1) perror("open"),exit(-1);
fread(arr,sizeof(int),5,p_file);
fclose(p_file);
二:在UNIX中关于文件的操作
int fd = open("a.txt",O_RDONLY|O_CREAT|O_TUEN,0666);
if (fd == -1)perror("open"),exit(-1);
write(fd,"hello",5);
close(fd);
int buff[10];
int res = read(fd,buff,sizeof(buff));
printf("res=%d,buff=%s\r\n",res,buff); //res = 5,buff = hello;
相关文章推荐
- 支付宝扫描二维码登录网站
- mybatis springmvc调用oracle存储过程,返回记录集
- CSS中float的用法
- 优高胜O2O模式
- java实现单链表之逆序
- 请千万当心:警惕云使用过程中的分析瘫痪问题
- GCD 深入理解(一)
- 一小时了解数据挖掘⑥数据挖掘的评估和结果可视化展示
- 剑指off-求二叉树高
- [随 笔]iOS提醒笔记
- 安卓IDE下载
- selemium 官网打不开怎么办
- oracle 数据库创建表空间和用户
- 聊聊高并发(四十三)解析java.util.concurrent各个组件(十九) 任务的定时执行和周期执行
- Android SimpleAdapter 的list刷新问题。
- IOS开发-CGAffineTransform的用法,实现一些简单动画效果
- Java进程堆外内存(off heap)大小
- 关于cocos2dx里面的onKeyDown返回按钮的问题
- FileMaker中的脚本学习
- Linux/UNIX下 ssh-keygen 设置SSH无密码登录