Created
September 19, 2014 12:08
-
-
Save samuelsmal/76078eb2fc4594ef8b3e to your computer and use it in GitHub Desktop.
c++ read by line
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
std::string line; | |
std::string _first_name, _last_name; | |
long _yearly_salary; | |
int _age, _clearance_level; | |
while (std::getline(input_file_stream, line)) | |
{ | |
std::istringstream iss(line); | |
if (!(iss >> _last_name >> _first_name >> _yearly_salary >> _age >> _clearance_level)) { break; } // error | |
employees.push_back(EmployeeRecord(_last_name, _first_name, _yearly_salary, _age, _clearance_level)); | |
} | |
input_file_stream.close(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment