Skip to content

Instantly share code, notes, and snippets.

@bdesham
Created June 13, 2011 20:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bdesham/1023627 to your computer and use it in GitHub Desktop.
Save bdesham/1023627 to your computer and use it in GitHub Desktop.
Read lines from a file in C++
// <iostream> and <fstream> have been included
void lines() {
ifstream in_file;
in_file.open("input.txt");
string line;
while (in_file.getline(line, 256)) {
cout << "line: \"" << line << "\"\n";
}
in_file.close();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment