TYPES OF FILES


There are 2 kinds of files in which data can be stored in 2 ways either in characters coded in their ASCII character set or in binary format. They are

  1. Text Files.
  2. Binary Files

TEXT FILES

A Text file contains only the text information like alphabets ,digits and special symbols. The ASCII code of these characters are stored in these files.It uses only 7 bits allowing 8 bit to be zero.

1.w(write):
This mode opens new file on the disk for writing.If the file exist,disk for writing.If the file exist, then it will be over written without then it will be over written without any confirmation.

SYNTAX:

fp=fopen("data.txt","w");
"data.txt" is  filename
"w" is writemode. 


2. r (read)
This mode opens an preexisting file for reading.If the file doesn’t Exist then the compiler returns a NULL to the file pointer
SYNTAX:

fp=fopen("data.txt","r");

3. w+(read and write)
This mode searches for a file if it is found contents are destroyed If the file doesn’t found a new file is created.
SYNTAX:

fp=fopen("data.txt","w+");

4.a(append)
This mode opens a preexisting file for appending the data.
SYNTAX:

fp=fopen("data.txt","a");

5.a+(append+read)
the end of the file.
SYNTAX:

fp=fopen("data.txt","a+");

6.r+ (read +write)
This mode is used for both Reading and writing