xii
Contents
in Detail
3.6
Portability Issues.......................................................................................................... 61
3.6.1
Feature Test Macros ................................................................................ 61
3.6.2
System Data Types.................................................................................. 63
3.6.3
Miscellaneous Portability Issues................................................................. 66
3.7
Summary.................................................................................................................... 68
3.8
Exercise ..................................................................................................................... 68
4
FILE I/O: THE UNIVERSAL I/O MODEL
69
4.1
Overview ................................................................................................................... 69
4.2
Universality of I/O ...................................................................................................... 72
4.3
Opening a File:
open()
................................................................................................. 72
4.3.1
The
open()
flags
Argument........................................................................ 74
4.3.2
Errors from
open()
................................................................................... 77
4.3.3
The
creat()
System Call ............................................................................ 78
4.4
Reading from a File:
read()
........................................................................................... 79
4.5
Writing to a File:
write()
............................................................................................... 80
4.6
Closing a File:
close()
................................................................................................... 80
4.7
Changing the File Offset:
lseek()
.................................................................................... 81
4.8
Operations Outside the Universal I/O Model:
ioctl()
....................................................... 86
4.9
Summary.................................................................................................................... 86
4.10
Exercises .................................................................................................................... 87
Chia sẻ với bạn bè của bạn: