Skip to content

Instantly share code, notes, and snippets.

@wohhie
Created September 6, 2016 06:15
Show Gist options
  • Save wohhie/8e937bb2c799f0bdab981d6901b1dbcf to your computer and use it in GitHub Desktop.
Save wohhie/8e937bb2c799f0bdab981d6901b1dbcf to your computer and use it in GitHub Desktop.
Create File & Read File
#include <iostream>
#include <fstream>
using namespace std;
int main() {
ofstream myfile("wohhie.txt");
if (myfile.is_open()) {
myfile << "This is Line 1\n";
myfile << "This is line 2\n";
myfile.close();
}
else {
cout << "Unable to write.";
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment