Oct
29

Write To A Text File

By

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;
}
Categories : Cpp, Notes

Leave a Comment

You must be logged in to post a comment.