3. Introduction
File is a collection of bytes on a secondary storage
device
It is a generally disk of some kind
Bytes may be interpreted like as character, word ,line
and paragraph
It is simply machine decipherable storage media
where data and programs are stored
4. Reading file
When r is used, the file is opened for reading
W is used for indicate a file used for writing
Indicates that you desire to append additional data to
the already in an existing file
Using the r indicate that the file is assumed to be a text
file already exist
If file not exit the fill pointer is set to be null
5. Examples for read
/*program to display the contents of a fj
#include<stdio.h>
Void main ()
{
File *fopen (), *fp;
Int c;
Fp=fopen(“prog.c”,r);
While (c!=edf)
{
7. Writing “w”
File is opened for writing
It will be create if it does not already exist
It will be reset if does ,resulting in the any data already
there
Using the w indicates that the file is assumed to be a
text file
8. Example
#include<stdio.h>
int main ()
{
File *fp;
File =fopen(“file.txt”,”w”) ;
/*create a file and a text /*
Fprintf(fp,“%s”,”this is just an example ”) ;/*writr data
to the file /*