Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Creating a new file

Status
Not open for further replies.

Marcus3

Programmer
Sep 14, 2001
2
GB
I need to be able to write a program that will create a new .txt file.

I cant use VB for this, as it needs to be able to run through DOS.

I am a real newbie at c++ (more a vb guy) so please give a good site or be descriptive.

Thanks.
 
In C++ we use an iostream class; here is some sample code, you can use this as a basis for learning more:

#include <iostream> //these are C++ header files
#include <fstream>

using namespace std; //C++ manages namespace better

// construct an ofstream (output file stream) object
ofstream myOutputFile(&quot;filename.txt&quot;);

// write to it
myOutputFile << &quot;god bless America&quot; << endl;

// close it
myOutputFile.close();

TO learn more about these things, do a search on C++ I/O streams and C++ file I/0. It is a complex subject matter with many nuances. But once you learn it you find it is more powerful than either VB or C.


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top