fork(1) download
  1. #include <iostream>
  2. #include <vector>
  3.  
  4. using namespace std;
  5.  
  6. struct Person {
  7. unsigned int id;
  8. std::string name;
  9. uint8_t age;
  10. // ...
  11. };
  12.  
  13. int main() {
  14.  
  15. std::istream& ifs = cin; // Open file alternatively
  16. std::vector<Person> persons;
  17.  
  18. Person actRecord;
  19. while(ifs >> actRecord.id >> actRecord.name >> actRecord.age) {
  20. persons.push_back(actRecord);
  21. }
  22.  
  23. if(!ifs) {
  24. std::cerr << "Input format error!" << std::endl;
  25. return -1;
  26. }
  27. return 0;
  28. }
Runtime error #stdin #stdout #stderr 0s 3476KB
stdin
1267867 John     Smith    32
67545   Jane     Doe      36
8677453 Gwyneth  Miller   56
75543   J. Ross  Unusual  23
stdout
Standard output is empty
stderr
Input format error!