Why files are needed ??

When a program is Finished , the data is lost. Storing data in a file will preserve your data even if the program terminates.   

data can easily move from one computer to another without any changes .

File I/O:- 

it is necessary to store the data in a manner that can be later retrieved and displayed either in a part or in whole. This medium is usually a “file” on the disk. File I/O can be handled by using different functions. 

a) Formatted functions:- The file input function fscanf( ) and the file output function fprintf( ) are called formatted file I/O functions. 

b)Unformatted functions:- The input functions like getc( ), getw( ), and fread( ) are called unformatted file input functions and putc( ), putw( ), and fwrite( ) functions are unformatted file output functions. Each and every function is having its own syntax and meaning.


File streams:- Stream is either reading or writing of data. The streams are designed to allow the user to access the files efficiently. A stream is a file or physical device like key board, printer, monitor, etc., The FILE object uses these devices. When a C program is started, the operating system is responsible for opening three streams: standard input stream (stdin), standard output stream (stdout), standard error(stderr).Normally the stdin is connected to the keyboard, the stdout and stderr are connected to the monitor. 

Files 

File is a collection of bytes that is stored in Hard disk.