fork download
  1. #include <iostream>
  2. #include <sstream>
  3. #include <string>
  4.  
  5. int main()
  6. {
  7. std::stringstream s("1 2 3 4 5 6 7 8 9");
  8. int n = 0;
  9. int x;
  10. while (s >> x)
  11. n += x;
  12.  
  13. std::cout << n << std::endl;
  14.  
  15. return 0;
  16. }
  17.  
Success #stdin #stdout 0s 2984KB
stdin
Standard input is empty
stdout
45