fgets()

<PAGE178>

#include <stdio.h >

char *fgets(char *restrict buf, int n,FILE *restrict fp)

fgets():

Line-at-a-time input (每次仅读取一行输入的函数)

buf:

       the buffer to read the line into(内存空间,用于存放读取到的一行数据)

n:

       sizeof line(一行数据的总数)

fp:

       the specified stream

return:

       buf if OK, NULLon end of file or error

remarks:

       This function reads up through and including the next newline,but no more than n–1 characters, into the buffer(猜测fgets应该是以读取到\r\n来结束)

       The buffer is terminated with a null byte

If theline, including the terminating newline , only a partial line is returned(可见在一行中若出现null的结束符,fgets会提前返回buffer数据)

Summarize

1.      fgets\r\n作为一行结束的标志

2.      一行数据当中若出现null结束符,fgets会提前返回buffer数据

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值