免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 883 | 回复: 0
打印 上一主题 下一主题

Unix编程[二] read [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2010-01-18 12:12 |只看该作者 |倒序浏览

                                如果函数执行成功会返回读到的字节数,如果到达文件尾,则返回0.当实际读到的数据字节数小于参数中指定的字节数时,会有以下几种情况:
  • When reading from a regular file, if the end
    of file is reached before the requested number of bytes has been read.
    For example, if 30 bytes remain until the end of file and we try to
    read 100 bytes, read returns 30. The next time we call read, it will return 0 (end of file).
  • When reading from a terminal device. Normally, up to one line is read at a time.
  • When reading from a network. Buffering within the network may cause less than the requested amount to be returned.
  • When reading from a pipe or FIFO. If the pipe contains fewer bytes than requested, read will return only what is available.
  • When
    reading from a record-oriented device. Some record-oriented devices,
    such as magnetic tape, can return up to a single record at a time.
  • When interrupted by a signal and a partial amount of data has already been read.

               
               
               
               
               
               

本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u2/87597/showart_2151929.html
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP