C++ – How Create a Text File and Write in It

C++ – Creating and writing to a file.

In C++ we have the following classes to perform output and input operations of characters from/to files:

ofstream:  class to write on files
ifstream: class to read from files
fstream:  class to both read and write from/to files.

So in order to create a file and write to it we will use ofstream class.

Let’s say we want to create a file called codebind.txt and write something in it.



Partner Sites




  • Snorre

    where are the file saved?