标准IO库 知识点百问《APUE》 chapter-5

20 篇文章 0 订阅

1-标准IO库提供的三种类型的buffering:

  • Fully buffered(全缓冲)
  • Line buffered(行缓冲)
  • unbuffered(无缓冲):典型标准错误流

2-行缓冲会遇到的两个问题:

  • 遇到新行符号前填满了buffer
  • 所有line-buffered和unbuffered stream输入请求都会flush line-buffered的输出流

3-三个标准流采用哪种buffering:

  1. 标准error总是unbuffered
  2. 标准input/output 在 terminal device的时候是line buffered;否则是fully buffered

4-对于打开的流,有三种无形式IO(unformated IO):

  1. Character-at-a-time I/O. We can read or write one character at a time。
  2. Line-at-a-time I/O. If we want to read orwrite a line at a time, we use fgets and fputs.
  3. Direct I/O(binary I/O). This type of I/O is supported by the fread and fwritefunctions. These two functions are often used for binary files where we read or write a structure with each operation.

5-getcfgetc之间的差别?以及注意点?

getc
fgetc函数
1. getc的参数一定不能是有副作用的表达式
2. 可以使用fgetc的地址,作为函数指针传入其他function
3. 调用fgetc消耗的时间比getc

6-一般文件的缓冲模式?

默认全缓冲

7-临时文件有哪些相关调用?

tmpnam,tempnam
tmpfile, mkstemp

8-tmpnam,tempname的缺点?

在返回唯一pathname和用该pathname创建临时文件之间有一段空隙。其他的进程可能在该空隙内用同样的pathname创建了文件。这样会导致严重的后果。

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

猎羽

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值