Skip to content

Instantly share code, notes, and snippets.

@wohhie
Created September 6, 2016 06:17
Show Gist options
  • Save wohhie/00007b466bb8c6fca9a51149bef6497e to your computer and use it in GitHub Desktop.
Save wohhie/00007b466bb8c6fca9a51149bef6497e to your computer and use it in GitHub Desktop.
Read From File
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
int main() {
string line;
ifstream myfile("wohhie.txt");
if (myfile.is_open()) {
while (getline(myfile, line)) {
cout << line << endl;
}
}
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