1
,What is a file?
• A named collection of data, stored in secondary
storage (typically).
• Typical operations on files:
– Open
– Read
– Write
– Close
• How is a file stored?
– Stored as sequence of bytes, logically contiguous (may not be
physically contiguous on disk).
2
, – The last byte of a file contains the end-of-file character (EOF),
with ASCII code 1A (hex).
– While reading a text file, the EOF character can be checked to
know the end.
• Two kinds of files:
– Text :: contains ASCII codes only
– Binary :: can contain non-ASCII characters
• Image, audio, video, executable, etc.
• To check the end of file here, the file size value (also stored on
disk) needs to be checked.
3