pl... answer me this question .. urgent

vignesh1988i's Avatar
Banned
file handling in C , consists of an important mode called "rb" , "wb" , "r+b" , "w+b" ... actually what does it mean...

plz... help me out
SaswatPadhi's Avatar, Join Date: May 2009
~ Б0ЯИ Τ0 С0δЭ ~
Check this : http://www.cplusplus.com/reference/c.../cstdio/fopen/
murugaperumal's Avatar, Join Date: Feb 2010
Go4Expert Member
Dear Friend,

I have explained the mode which is used in the fopen function.

r or rb
Open file for reading.
w or wb
Truncate to zero length or create file for writing.
a or ab
Append; open or create file for writing at end-of-file.
r+ or rb+ or r+b
Open file for update (reading and writing).
w+ or wb+ or w+b
Truncate to zero length or create file for update.
a+ or ab+ or a+b
Append; open or create file for update, writing at end-of-file.

open or createThe character 'b' shall have no effect, but is allowed for ISO C standard conformance
rekha_sri's Avatar, Join Date: Feb 2010
Light Poster
Hi,
Following explanations for fopen() function different modes.

rb Open a binary file for reading. The file which is specified in the
fopen() must be exist. wb Create an empty binary file for writing. If the file exists, file contents will be cleared unless it is a logical file. ab Open a binary file in append mode for writing at the end of the file. If file is doesn't exist fopen() function will create the file. r+b or rb+ Open a binary file for both reading and writing. The file must be exist. w+b or wb+ Create an empty binary file for both reading and writing. If the file exists, file contents will be cleared unless it is a logical file. a+b or ab+ Open a binary file in append mode for writing at the end of the file. If file is does not exist fopen() function will create the file.