fork(1) download
  1. #include <iostream>
  2. #include <string>
  3. #include <fstream>
  4. #include <vector>
  5. using namespace std;
  6.  
  7. struct employee
  8. {
  9. string name;
  10. double pay_rate;
  11. };
  12.  
  13. int ID;
  14. void load_data(vector<employee>& v)
  15. {
  16. string t;
  17. getline(cin, t);
  18. ID = stoi(string(t.begin() + t.rfind("#") + 1, t.end()));
  19.  
  20. employee e;
  21. while(getline(cin >> ws, e.name, ':') >> ws >> e.pay_rate)
  22. {
  23. v.push_back(e);
  24. }
  25. }
  26.  
  27. int main() {
  28. vector<employee> employees;
  29. load_data(employees);
  30.  
  31. cout << "ID: " << ID << endl;
  32. for(auto e : employees)
  33. cout << e.name << ": " << e.pay_rate << endl;
  34.  
  35. }
Success #stdin #stdout 0s 3480KB
stdin
#FILE#48027599
John Doe: 32000
Jane Doe: 35000
stdout
ID: 48027599
John Doe: 32000
Jane Doe: 35000