9. Advance way of handling files in C++
Hello folks!
Welcome to this blog
series. In
the previous blog we have studied basic file handling in C++. In this blog we will see some
more advance ways of file handling in C++, so let’s get started.
Advance
way of handling files in C++
There can be different
purpose of opening a file. For example to write on the file, to read from the
file, etc. These are the different modes in which we can open a file in C++.
Mode
|
Description
|
ios::app
|
To
open a text file for appending purpose.
|
ios::ate
|
To
open a file for output purpose and move the read/write control to the end of
the file.
|
ios::in
|
To
open a text file for reading purpose.
|
ios::out
|
To
open a text file for writing purpose.
|
ios::trunc
|
To
truncate the file content before opening a file, if file already exists in
our system.
|
Let’s understand this
with an example code.
Code:
Output:
Files
before running the code:
Files
after running the code:
So we now know how to play with files in C++. So we
will meet you in our next blog where we will discuss, how we implemented the
system in C++ with its code explained.
By-
Ashutosh Bardapurkar (k-05)
Hrishikesh Deshpande (k-16)
Archit Hiwrekar
(k-23)
Chinmay Kapkar (k-33)
Solved all my douts
ReplyDeleteThank you !!!