+ 1

What about writing to files?

I need to write to a file on my harddisk. How can I do this with C++?

15th Oct 2016, 11:05 PM
Robert Krischik
Robert Krischik - avatar
2 Antworten
+ 2
#include <fstream> header file.
15th Oct 2016, 11:14 PM
Cohen Creber
Cohen Creber - avatar
+ 2
a example of how to write in a file: #include <iostream> #include <fstream> using namespace std; int main(){ fstream archive; archive.open("anytext.txt"); if(archive.fail()){ cout << "error opening file\n"; return 1; } string x = "abcde"; archive << x; archive.close(); return 0; }
16th Oct 2016, 1:59 AM
Hector Sulbaran
Hector Sulbaran - avatar