Saturday, 31 August 2013

FILES | C Programming Language Tutorial



FILES

A file is a place on disk where group of related data are stored. C supports a number of functions that have the ability to perform basic file operations, which
include:
=> Naming a file
=> Opening the file
=> Reading data from the file
=> Writing data to the file
=> Closing the file
There are two distinct ways to perform file operations in C. The first one is known as the low level I/O and uses UNIX system calls. The second method is referred to as the high level I/O operation and uses functions in C's standard I/O library.

FILE TYPES:
DOS treats files in two different ways viz., as binary or text files. Almost all UNIX Systems do not make any distinction between the two. If a file is specified as the binary type, the file I/O functions do not interpret the contents of the file when they read from or write to the· file. But, if the file is specified as the text type the I/O functions interpret the contents of the file.
The basic differences in these two types of files are:
I. ASCII 0xla is considered an end-of-file character by the file I/O function when reading from a text file and they assume that the end of the file has
been reached.
II. In case of DOS a new file is stored as the sequence 0*0d 0*0a on the disk in case of text files. UNIX stores \n as 0* 0a both on disk and in memory.

0 comments:

Post a Comment

 

C Programming Language Interview Questions and Answers Tutorial for beginners. Copyright 2013 All Rights Reserved