3
Contributors
2
Replies
4
Views
7 Years
Discussion Span
Last Post by nbaztec
0

If u want to update or append to a text file using fopen function call, u can use both "a" and "a+" access modes. For binary an additional "b" character has to be included in the mode string (i.e ab and ab+ or a+b).

Mode a : Appends to a file. Writing operations appends data at the end of the file.

Mode a+ : Opens a file for reading and appending. All writing operations are performed at the end of the file, protecting the previous content to be overwritten. U can reposition (fseek, rewind) the internal pointer to anywhere in the file for reading, but writing operations will move it back to the end of file.

Note : In both the cases the file is created if it does not exist.

Cheers,

0

If u want to update or append to a text file using fopen function call, u can use both "a" and "a+" access modes. For binary an additional "b" character has to be included in the mode string (i.e ab and ab+ or a+b).

Mode a : Appends to a file. Writing operations appends data at the end of the file.

Mode a+ : Opens a file for reading and appending. All writing operations are performed at the end of the file, protecting the previous content to be overwritten. U can reposition (fseek, rewind) the internal pointer to anywhere in the file for reading, but writing operations will move it back to the end of file.

Note : In both the cases the file is created if it does not exist.

This is C FILE *
In C++ we have better fstream Objects having modes:

ios::in
ios::out
ios::in | ios::out
ios::ate
ios::app
ios::binary //Can be used with all above
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.