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




Stuff I use to make videos

Windows notebook – http://amzn.to/2zcXPyF

Apple MacBook Pro – http://amzn.to/2BTJBZ7

Desktop - http://amzn.to/2zct252

Microphone – http://amzn.to/2zcYbW1

notebook mouse – http://amzn.to/2BVs4Q3

Screen Recording Software – Camtasia