[Operating System] Files

File is a logical collection of 1's and 0's. There are two basic types of files:

  1. Text / ASCII files:
    1. Plain printable text. Generally human readable and editable.
    2. Examples: .c, .java, .txt.
  2. Binary files:
    1. Everything other than text files. It's kind of a misnomer, because text files are essentially binary as well.
    2. Generally not human readable and editable. 
    3. Usually generated and interpreted by some program.
Endianness:

Endianness refers to how the binary data in a file is ordered. There are two types of Endianness conventions:
  1. Big Endian: bytes are stored in file from most significant bits (MSB) to least significant bits (LSB). Example: CADE 0000 0002
  2. Little Endian: bytes are stored in file from LSB to MSB. Example: DECA 0000 0200
In the UNIX operating system, I/O devices are modeled as files. You could open them, write bytes to them, and read bytes from them.

C library defines three constant (always open, cannot close) file handlers:
  1. stdin: standard input (console).
  2. stdout: standard output (console).
  3. stderr: standard error (console, for error message).

Comments

Popular posts from this blog

[LeetCode] 631. Design Excel Sum Formula

[LeetCode] 714. Best Time to Buy and Sell Stock with Transaction Fee

[LeetCode] 269. Alien Dictionary