Linux&C open creat read write lseek 函数用法总结


一:五个函数的参数以及返回值。

函数
                                参数                      返回值    
open (文件名,打开方式以及读写方式,文件的权限) 读取成功返回文件描述符fd(0-255),
失败返回-1   
creat (char*(文件名称),文件的权限) 创建成功返回文件描述符,失败返回-1
read    (fd,read_buf(缓存区,相当于一块空间),count(要读的长度)) 读取成功返回读取的长度,读取
失败返回-1
write     (fd,write_buf(要写入文件的内容,路径),count(要写入的字节)) 写入成功返回写入的长度,写入失败返回-1
lseek      (fd,offset(移动的量),从什么位置) 移动成功返回从文件开头到现在指针位置的字节
二:代码实例:
1:open :https://github.com/yangbodong22011/linuxc/blob/master/20150719/my_creat.c
2:creat:https://github.com/yangbodong22011/linuxc/blob/master/20150721/umask.c
3:read:https://github.com/yangbodong22011/linuxc/blob/master/20150720/read.c
4:write:https://github.com/yangbodong22011/linuxc/blob/master/20150721/unlink.c
5:lseek:https://github.com/yangbodong22011/linuxc/blob/master/20150720/my_lseek.c

阅读(1) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~
评论热议

版权声明:本文为博主原创文章,未经博主允许不得转载。

posted on 2015-08-04 21:07  杨博东的博客  阅读(182)  评论(0编辑  收藏  举报

导航