Created
November 11, 2016 12:40
-
-
Save tterb/96d25e58c0ca3c5b0bd874235016d388 to your computer and use it in GitHub Desktop.
Read from a file in C++
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ifstream fileIn(filename.c_str()); | |
if(!fileIn) | |
cerr << "ERROR: Unable to read from " << filename << endl; | |
string line; | |
while(getline(fileIn, line)) { // read line into a vector | |
input.push_back(line); | |
line.clear(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment