Programming with C

⌘K
  1. Home
  2. Docs
  3. Programming with C
  4. File Processing
  5. Files

Files

  • File is a named location on the system storage which records data for later access
  • It is stored in a non-volatile memory
  • A unique path name of the file must be given to access the file for reading and modification purpose
  • C view’s each file as a sequential stream of bytes
  • Each file ends with either an end – of file marker

When a file is opened, a stream is associated with it.

Three streams are automatically opened when program execution begins:

  •  the standard input (which receives input from the keyboard),
  •  the standard output (which displays output on the screen) and
  •  the standard error (which displays error messages on the screen)

Communication Channels

Streams provide communication channels between files and programs.

For example, the standard input stream enables a program to read data from the keyboard, and the standard output stream enables a program to print data on the screen.

Files are classified into text file and binary file,

Text file:

  • Text files are structured as a sequence of lines, where each line includes a sequence of characters.
  • Each line is terminated with a special character, called the EOL or End of line character
  • They are identified with .txt file

Binary File:

  • Binary file is a file stored in binary format
  • A binary file is machine – readable but not computer readable
  • All executable programs are stored in binary files
  • They are identified as .bin, .dat

File structure

  • Opening a file returns a pointer to a FILE structure (defined in) that contains information used to process the file.
  • In some operating systems, this structure includes a file descriptor, i.e., an integer index into an operating-system array called the open file table.
  • Each array element contains a file control block (FCB)—information that the op[1]erating system uses to administer a particular file.
  • The standard input, standard output and standard error are manipulated using stdin, stdout and stderr.

Views: 0

How can we help?

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments