Mode | Description |
---|---|
r | Represents open a file for read.File pointer points to the initial point of the file. |
w | Represents open empty file for writing.File pointer points to the initial point of the file. |
a | Represents open a file to append the data to the existing file without erasing the existing data. File pointer begins at the end of the file. If no file exist, a new file is created. |
x | Represent creation of a new file for write purpose only. Returns FALSE and an error if file already exists. |
r+ | Represents open a binary file for read and write.File pointer points to the initial point of the file. |
w+ | Represents open a binary file for write and read |
r+ | Represents open a binary file for append and read |
x+ | represents creation of a new file to read/write. Returns FALSE and an error if file already exists. |
fopen()
function. Always do not forgot to close the file once the task is completed.It is a good programming practice to close the file after completing the task, so that server resources will not be wasted.