In fopen(), it is necessary to provide opening mode with the file name. Opening mode can control operation performed on opened text file or binary file.
File opening mode and their purpose are represented in following tables :-
fopen() में file के नाम के साथ उसका ओपनिंग मोड देना आवश्यक होता है, ओपनिंग मोड यह नियंत्रित करता है कि खुली हुई टेक्स्ट या बाइनरी फाइल पर कौन-कौन से ऑपरेशन किये जायेंगे।
fopen() में file के नाम के साथ उसका ओपनिंग मोड देना आवश्यक होता है, ओपनिंग मोड यह नियंत्रित करता है कि खुली हुई टेक्स्ट या बाइनरी फाइल पर कौन-कौन से ऑपरेशन किये जायेंगे।
फाइल ओपनिंग मोड एवं उनके उद्देश्य को निम्न तालिका में दर्शाया गया है-
TEXT FILE OPENING MODES | ||||
S.No. | Opening mode | Role | If the file already exit | If the file does not exit |
1) | r (पढ़ना) | reading a file | open a file read only not write | operation fail return NULL |
2) | w (लिखना) | writing a file and save | over write existing it means previous file content are replace with new content | create a file write and save it |
3) | a (संलग्न करना) | appending text into file | new information is added to the file after EOF | create a new file and write |
4) | r+ | reading +writing a file (update) | new text is written after existing file data | creates a new file |
5) | w+ | reading +writing a file | previous file data will be erased or delete first and then new data is written at the begaining of the file | creates a new file |
6) | a+ | reading +appending a file | new data is written after EOF and we can read previous data also | creates a new file |
BINARY FILE OPENING MODES | ||||
S.No. | Opening mode | Role | If the binary file already exit | If the binary file does not exit |
1) | rb | reading a binary file | open a binary file read only not write | operation fail return NULL |
2) | wb | writing a binary file and save | over write existing it means previous binary file content are replace with new content | create a binary file write and save it |
3) | ab | appending binary bytes into binary file | new information is added to the binary file after EOF | create a new binary file and write |
4) | rb+ | reading +writing a binary file (update) | new data is written after existing binary file data | creates a new binary file |
5) | wb+ | reading +writing a binary file | previous binary file data will be erased or delete first and then new data is written at the begining of the binary file | creates a new binary file |
6) | ab+ | reading +appending a binary file | new data is written after EOF and we can read previous data also | creates a new binary file |
No comments:
Post a Comment