FILE opening mode of fopen() in C language

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 के नाम के साथ उसका ओपनिंग मोड देना आवश्यक होता है, ओपनिंग मोड यह नियंत्रित करता  है कि खुली हुई टेक्स्ट या बाइनरी फाइल पर कौन-कौन से ऑपरेशन किये जायेंगे।
फाइल ओपनिंग मोड एवं उनके उद्देश्य को निम्न तालिका में दर्शाया गया है-       

TEXT FILE OPENING MODES
S.No.Opening modeRoleIf the file already exitIf the file does not exit
1)r  (पढ़ना)reading a fileopen a file read only not writeoperation fail return NULL
2)w (लिखना) writing a file and saveover write existing it means previous file content are replace with new contentcreate a file write and save it
3)a  (संलग्न करना) appending text into filenew information is added to the file after EOFcreate a new file and write
4)r+reading +writing a file (update)new text is written after existing file datacreates a new file
5)w+reading +writing a fileprevious file data will be erased or delete first and then new data is written at the begaining of the filecreates a new file
6)a+reading +appending a filenew data is written after EOF and we can read previous data alsocreates a new file
BINARY FILE OPENING MODES
S.No.Opening modeRoleIf the binary file already exitIf the binary file does not exit
1)rbreading a binary fileopen a binary file read only not writeoperation fail return NULL
2)wbwriting a binary file and saveover write existing it means previous binary file content are replace with new contentcreate a binary file write and save it
3)abappending binary bytes into binary filenew information is added to the binary file after EOFcreate a new binary file and write
4)rb+reading +writing a binary file (update)new data is written after existing binary file datacreates a new binary file
5)wb+reading +writing a binary fileprevious binary file data will be erased or delete first and then new data is written at the begining of the binary filecreates a new binary file
6)ab+reading +appending a binary filenew data is written after EOF and we can read previous data alsocreates a new binary file

No comments:

Post a Comment