在linux中read、write函数
来源:互联网 发布:新初一数学网络课程 编辑:程序博客网 时间:2024/06/01 08:40
read函数从打开的设备或文件中读取数据。
- #include<</span>unistd.h>
- ssize_t read(int
fd, void *buf, size_tcount);
描述:参数count是请求读取的字节数,读上来的数据保存在缓冲区buf中,同时文件的当前读写位置向后移。(注意:这个读写位置和使用C标准I/O库时的读写位置有可能不同,这个读写位置是记在内核中的,而使用C标准I/O库时的读写位置是用户空间I/O缓冲区中的位置。)
返回值:若成功返回读到的字节数;若已到达文件结尾返回0;若出错返回-1;
注:有多种情况会出现实际读到的字节数少于要求读的字节数(count)。
●读普通文件时,在读到要求的字节数(count)之前已到达了文件尾端。
●从终端设备读,通常以行为单位,一次最多读一行,读到换行符就返回了。
●从网络读,根据不同的传输层协议和内核缓存机制,网络中的缓冲机构可能造成返回值可能小于请求的字节数。
write函数向打开的设备或文件中写数据.
- #include<</span>unistd.h>
- ssize_t write(int
fd, const void *buf, size_tcount);
写常规文件时,write的返回值通常等于请求写的字节数count,而向终端设备或网络写则不一定。
返回值:若成功返回写入到设备或文件中的字节数;若失败返回-1;
- 在linux中read、write函数
- LINUX C中read,write
- Linux -C 的read 和 write函数
- linux下 open() write() read() close函数
- Linux -C 的read 和 write函数
- linux系统函数read和write
- linux下 open() write() read() close函数
- linux下 open() write() read() close函数
- linux下 open() write() read() close函数
- linux下 open() write() read() close函数
- Linux下的read,write函数
- linux下 open() write() read() close函数
- Unix/Linux中的read和write函数
- linux下 open() write() read() close函数
- Unix/Linux中的read和write函数
- linux-终端read和write函数
- Unix/Linux中的read和write函数
- linux下 open() write() read() close函数
- IAR FOR ARM 各版…
- RedHat Enterprise Linu…
- 【转】教你如何实现linux和W…
- Ubuntu+Win7+Samba实现文件共享
- 30天自制操作系统笔记(九十)
- 在linux中read、write函数
- linux中memset的正确用法
- linux管道通信
- linux中open函数使用
- 进程间通信___命名管道(FIFO)
- linux中stdout,stdin,stderr意义
- 在linux中获取错误返回信息 &…
- 我的博客今天0岁52天了,我领取了…
- 成都国嵌-嵌入式linux必修实验手册…