Skip to content

Instantly share code, notes, and snippets.

@samuelsmal
Created September 19, 2014 12:08
Show Gist options
  • Save samuelsmal/76078eb2fc4594ef8b3e to your computer and use it in GitHub Desktop.
Save samuelsmal/76078eb2fc4594ef8b3e to your computer and use it in GitHub Desktop.
c++ read by line
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