23-01-2012, 03:29 PM
File Handling in C
FilesinC lecture.doc (Size: 77 KB / Downloads: 191)
We frequently use files for storing information which can be processed by our programs. In order to store information permanently and retrieve it we need to use files.
Files are not only used for data. Our programs are also stored in files.
The editor which you use to enter your program and save it, simply manipulates files for you.
File I/O
The Standard I/O Library provides similar routines for file I/O to those used for standard I/O.
The routine getc(fp) is similar to getchar()
and putc(c,fp) is similar to putchar©.
Thus the statement
c = getc(fp);
reads the next character from the file referenced by fp and the statement
putc(c,fp);
writes the character c into file referenced by fp.