您的位置:首页 > 其它

Chapter 1. General Unix and Advanced C

2011-07-19 22:46 288 查看
 
Computer Science from the Bottom Up
Prev Next

Chapter 1. General Unix and Advanced C

Table of ContentsEverything is a file!Abstraction and function pointersStandard File Descriptors

Everything is a file!

If you learn nothing else, you should remember that in UNIX everything is a file.
Imagine a file in the context something familiar like a word processor. There are two fundamental operations we can use on this imaginary word processing file

Read it (existing saved data from the word processor).

Write to it (new data from the user).

Now consider some of the common things attached to a computer and how they relate to our fundamental file operations.

The screen

The keyboard

A printer

A CDROM

The screen and printer are both like a write-only file, but instead of being stored as bits on a disk the information is displayer as dots on a screen or lines on a page. The keyboard is like a read only file with the data coming from keystrokes and the CDROM is similar but rather than randomly coming from the user the data is stored directly on the disk.
Thus a file is a good abstraction of all the devices attached to the computer. Some files may be read-only, or write-only, or indeed both.
Prev
Home
Next
About the course
 
Abstraction and function pointers
 
原文链接:http://bottomupcs.sourceforge.net/csbu/c57.htm
 
 
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息