fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. struct var {
  5. std::string name;
  6. double value;
  7. };
  8.  
  9. std::istream& operator>>(std::istream& s, var& x) {
  10. while (s.peek() == '\n') {
  11. s.get();
  12. }
  13. std::getline(s, x.name, ':');
  14. s >> x.value;
  15. return s;
  16. }
  17.  
  18. int main() {
  19. var v;
  20. while (cin >> v) {
  21. cout << v.name << " --- " << v.value << endl;
  22. }
  23. return 0;
  24. }
Success #stdin #stdout 0s 3276KB
stdin
quick:123
brown:456
fox:789


dead:
stdout
quick --- 123
brown --- 456
fox --- 789