您的位置:首页 > 产品设计 > UI/UE

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

2016-02-23 13:21 423 查看

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

Fully buffered(全缓冲)

Line buffered(行缓冲)

unbuffered(无缓冲):典型标准错误流

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

遇到新行符号前填满了buffer

所有line-buffered和
unbuffered
stream输入请求都会
flush
line-buffered的输出流

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

标准error总是
unbuffered


标准input/output 在
terminal device
的时候是
line buffered
;否则是
fully buffered


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

Character-at-a-time I/O
. We can
read
or
write
one character at a time。

Line-at-a-time I/O.
If we want to
read
or
write
a line at a time, we use fgets and fputs.

Direct I/O
(binary I/O). This type of I/O is supported by the
fread
and
fwrite
functions. These two functions are often used for
binary files
where we read or write a structure with each operation.

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

getc


fgetc
函数

1.
getc
的参数一定不能是有副作用的表达式

2. 可以使用
fgetc
的地址,作为函数指针传入其他function

3. 调用
fgetc
消耗的时间比
getc


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

默认全缓冲

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

tmpnam,tempnam

tmpfile, mkstemp

8-tmpnam,tempname的缺点?

在返回唯一pathname和用该pathname创建临时文件之间有一段空隙。其他的进程可能在该空隙内用同样的pathname创建了文件。这样会导致严重的后果。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: