In C++, reading and writing to files can be done by using I/O streams in conjunction with the stream operators >>  and << . When reading or writing to files, those operators are applied to an instance of a class representing a file on the hard drive. This stream-based approach has a huge advantage: From a C ++ perspective, it doesn’t matter what you are reading or writing to, whether it’s a file, a database, the console, or another PC you are connected to over the network. Therefore, knowing how to write files using stream operators can be transferred to other areas.

#c++

How to read and write files in C++
1.20 GEEK