Write To A Text File

This snippet will write a text file.


#include <fstream.h>

int main() {
    ofstream outfile("example.txt");
    if (outfile.is_open()) {
        outfile << "This is a line.n";
        outfile << "This is another line.n";
        outfile.close();
    }
    return 0;
}

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.