example the source code:
 
#include <iostream.h>
#include <fstream.h>
#include <conio.h>
int main()
{
 ofstream newtext;
 newtext.open("D:/notepadtitle.txt");

 newtext<<"visit http://yt-yusufruli.blogspot.com"<<endl;

 newtext.close();
 getch();
 return 0;
}

explanation of the above example:

Newtext.open command ("D: / notepadtitle.txt"); example.txt will open a file that is in drive D: / and will copy what we write into the file. As I write in the program, if previously we do not make example.txt files on drive D: /, then the file will be automatically made. And if we already have a file example.txt example.txt then all the file contents will be deleted and be replaced by what we type in the above program.
Here you may also see the first new <fstream.h> header files. Header is used to execute commands ofstream, without headers <fstream.h>, ofstream can not run! Ofstream is a command to open the file. While ifstream is a command to read the file.