File Processing
Stream
A sequence of character that are stored as data.
There are 3 types of streams:
- Input Stream
- Output Stream
- Error Stream
File
A collection of records
There are 2 types of file:
- Text File
- Binary File
Buffer Area
Part of the memory used as a temporary space before the data is moved to a file.
Syntax : FILE *fp;
Open File
To open a File, use fopen() : FILE *fopen (const char *filename, const char *mode );
fopen() : return a pointer to the start of a buffer area. Null will be returned if file is unable to open.
Possible mode Value :
“r” = opening a file to be read.
"w” = creating a file to be written.
“a” = opening a File for data append.
“r+” = opening a File for read/write.
“w+” = creating file for read/write.
“a+” = opening a File for read/append
“rb” = opening a File (binary) to be read.
“wb” = creating a file (binary) for write operation
Close File
To close file, use fclose() : int fclose (FILE *stream);
Comments
Post a Comment