http://programmingexamples.net/w/index.php?title=CPP/IO/FileOutput&feed=atom&action=history
CPP/IO/FileOutput - Revision history
2024-03-29T06:06:57Z
Revision history for this page on the wiki
MediaWiki 1.23.5
http://programmingexamples.net/w/index.php?title=CPP/IO/FileOutput&diff=73&oldid=prev
Daviddoria: Created page with '==FileOutput.cpp== <source lang="cpp"> #include <iostream> #include <fstream> void Overwrite(); void Append(); int main(int argc, char *argv[]) { Overwrite(); Append(); r…'
2010-06-23T12:26:20Z
<p>Created page with '==FileOutput.cpp== <source lang="cpp"> #include <iostream> #include <fstream> void Overwrite(); void Append(); int main(int argc, char *argv[]) { Overwrite(); Append(); r…'</p>
<p><b>New page</b></p><div>==FileOutput.cpp==<br />
<source lang="cpp"><br />
#include <iostream><br />
#include <fstream><br />
<br />
void Overwrite();<br />
void Append();<br />
<br />
int main(int argc, char *argv[])<br />
{<br />
Overwrite();<br />
Append();<br />
return 0;<br />
}<br />
<br />
void Overwrite()<br />
{<br />
//overwrite test.txt<br />
std::string Filename = "test.txt";<br />
std::ofstream fout(Filename.c_str());<br />
<br />
fout << 1 << std::endl << 2 << std::endl;<br />
<br />
fout.close();<br />
/*<br />
or<br />
ofstream fout;<br />
fout.open(Filename);<br />
*/<br />
}<br />
<br />
void Append()<br />
{<br />
std::string Filename = "append.txt";<br />
std::ofstream fout(Filename.c_str(), std::ios::app);<br />
<br />
fout << 1 << std::endl << 2 << std::endl;<br />
<br />
fout.close();<br />
}<br />
</source></div>
Daviddoria