Q:

How OS control files?

I know that each block of OS array contains one FCB. but I don't understand how OS uses them to control files. I don't understand the relation. PLZ explain simply.

A:

C views each file simply as a sequential stream of bytes. Each file ends either with an end-of-file marker or at a specific byte number recorded in a system-maintained, administrative data structure. When a file is opened, a stream is associated with the file. Three files and their associated streams are automatically opened when program execution begins- the standard input, the standard output and the standard error. Opening a file returns a pointer to a FILE structure (defineed in <sdtio.>) that contains information used to process the file. This structure includes a file descriptor, i.e., an index into an operating system array called open file table. Each array element contains a  file control block (FCB) that the operating system uses to administer a particular file. the standard input, standard output and standard error are maniulated using file pointers stdin, stdout and stderr.
Deitel, how to program C, 6th eidition, page 420

