ChinaUnix.net
相关文章推荐:

linux read write

代码很简单: 父进程向管道中写入"Hello,World!\n",子进程将管道中的数据读出存储到buf2,然后送到标准输出中。 问题是如果要写入的字符串超过了BUFFER_SIZE,应该怎样编写代码呢?求指点迷津阿[qq]373202184[/qq] 附上代码:[code]#include #include #include #include #include #include #define BUFFER_SIZE 100 int main(int argc, char **argv) { ...

by 373202184 - C/C++ - 2013-10-23 20:49:56 阅读(4270) 回复(5)

相关讨论

本帖最后由 飘扶摇 于 2011-05-26 23:41 编辑 ssize_t xxx_read(struct file *filp, char *buffer, size_t count, loff_t *ppos); ssize_t xxx_write(struct file *filp,const char *buffer, size_t count); 上面两个函数中的"buffer" 是什么时候分配出来的,分配在什么地方,是内核分配的吗?

by 飘扶摇 - 驱动开发 - 2011-06-18 16:46:50 阅读(5915) 回复(9)

简单的读一个文件: #include #include #include #include int main(int argc,char **argv) { int fd = 0; int pid = 0; char buffer[20] = {'\0'}; char *read_buffer[20] = {'\0'}; //fd = open("/dev/hello",O_RDWR | O_CREAT | O_TRUNC); fd = open("/dev/hello",O_RDONLY ); //| O_NONBLOCK); printf("fd=%d\n",fd); if(fd #include #include #inclu...

by edwinrong - Linux文档专区 - 2011-02-19 11:09:10 阅读(2242) 回复(1)

/******************************************** *Created By: 陶治江 *Date: 2009年5月2日0:42:11 ********************************************/ #include #include #include #include #include #include /*这里的代码更加优良了,所有的操作都被封装到了file->f_op->中的 *处理句柄中了,实际是在struct file中插入了结构 *struct file_operations元素了,我很喜欢这样的改变哦 :-)*/ //读取fd指向的目录到st...

by taozhijiangscu - Linux文档专区 - 2009-05-04 18:39:12 阅读(837) 回复(0)

一,read 函数从打开的设备或文件中读取数据 #include ssize_t read(int fd, void *buf, size_t count); 返回值:成功返回读取的字节数,出错返回-1并设置errno,如果在调read之前已到达文件末尾,则这次 read返回0 读上来的数据保存在缓冲区buf 中,同时文件的当前读写位置向后移。注意这个读写位置和使用C标准I/O库时的读写位置有可能不同,这个读写位置是记在内核中的,而使用C标准I/O库时的读写位置是用户空间I/...

by 逼良为娼 - Linux文档专区 - 2009-08-27 11:24:54 阅读(921) 回复(0)

<求助>简单linux socket程序,服务器write客户端read,不能成功! 这是客户端程序, 运行环境suse10, // socket client #include"mysocketdef.h" // inner func declare int my_inputstr(FILE* fp, int sockfd); int my_readServStr(int sockfd); int main(int argc, char* argv[]) { int sockfd; struct sockaddr_in servaddr; int ret ; if( 2 != argc ) { printf(" client usage:myclie...

by slugafei - 程序开发 - 2006-10-23 23:20:25 阅读(2965) 回复(2)

<求助>简单linux socket程序,服务器write客户端read,不能成功! 这是客户端程序, 运行环境suse10, // socket client #include"mysocketdef.h" // inner func declare int my_inputstr(FILE* fp, int sockfd); int my_readServStr(int sockfd); int main(int argc, char* argv[]) { int sockfd; struct sockaddr_in servaddr; int ret ; if( 2 != argc ) { printf(" client usage:myclie...

by slugafei - Linux环境编程 - 2006-10-23 23:20:25 阅读(1623) 回复(2)

open调用成功返回值是不是为0? read(filename,buffer,number),成功调用返回的值是不是读取的字节数number? write(filename,buffer,number),成功调用返回的值是不是写入文件的字节数number?

by wy200747055 - Linux环境编程 - 2012-06-12 12:54:19 阅读(5546) 回复(2)

linux文件设备与I/O:read/write函数 与 阻塞 Block 一,read 函数从打开的设备或文件中读取数据 #include ssize_t read(int fd, void *buf, size_t count); 返回值:成功返回读取的字节数,出错返回-1并设置errno,如果在调read之前已到达文件末尾,则这次 read返回0 读上来的数据保存在缓冲区buf 中,同时文件的当前读写位置向后移。注意这个读写位置和使用C标准I/O库时的读写位置有可能不同,这个读写位置是...

by wangxy-andy - Linux文档专区 - 2009-08-30 22:38:55 阅读(1366) 回复(0)

6. read 函数 6.1. 原型与参数 ssize_t read(unsigned int fd, char * buf, size_t count) read函数是从打开的文件中读取数据。如read成功,则返回读到的字节数。如已到达文件的尾端,则返回0。如果失败,则返回-1。有多种情况可使实际读到的字节数少于要求读字节数: • 读普通文件时,在读到要求字节数之前已到达了文件尾端。例如,若在到达文件尾端之前还有30个字节,而要求读100个字节,则read...

by hzg1031 - Linux文档专区 - 2009-04-30 15:38:45 阅读(2421) 回复(0)

我的意思是linux下的doc需要驱动吗。在dos下能找到doc,能顺利的read write。但是在linux 找不到doc。用fdisk -l 也看不到。不知怎样查看与加载doc。请问要doc驱动程序吗,还是用什么linux命 令能看到格式,然后加载上去,就可以了。多谢

by xuxd32 - Linux新手园地 - 2007-05-25 11:43:30 阅读(1271) 回复(1)