fork(1) download
  1. #include <iostream>
  2. #include <vector>
  3.  
  4. struct Person {
  5. unsigned int id;
  6. std::string name;
  7. uint8_t age;
  8. // ...
  9. };
  10.  
  11. int main() {
  12. std::istream& ifs = std::cin; // Open file alternatively
  13. std::vector<Person> persons;
  14.  
  15. Person actRecord;
  16. while(ifs >> actRecord.id >> actRecord.age &&
  17. std::getline(ifs, actRecord.name)) {
  18. persons.push_back(actRecord);
  19. }
  20.  
  21. return 0;
  22. }
Success #stdin #stdout 0s 3432KB
stdin
1267867 32  John     Smith    
67545   36  Jane     Doe      
8677453 56  Gwyneth  Miller   
75543   23  J. Ross  Unusual  
stdout
Standard output is empty