fork(1) download
  1. #include <iostream>
  2. #include <sstream>
  3. #include <locale>
  4. #include <vector>
  5. #include <iterator>
  6. struct dot_ws : std::ctype<char> {
  7. static const mask* make_table() {
  8. static std::vector<mask> v(classic_table(), classic_table() + table_size);
  9. v['.'] |= space; // dot will be classified as whitespace
  10. return &v[0];
  11. }
  12. dot_ws(std::size_t refs = 0) : ctype(make_table(), false, refs) {}
  13. };
  14. int main()
  15. {
  16. std::string YourStringName = "8573656.5465467.5435325.3253255";
  17.  
  18. std::istringstream ins(YourStringName);
  19. ins.imbue(std::locale(ins.getloc(), new dot_ws()));
  20. std::istream_iterator<long> beg(ins), end;
  21. std::vector<long> vectorLong(beg, end);
  22.  
  23. for(size_t n =0; n<vectorLong.size(); ++n)
  24. std::cout << vectorLong[n] << ' ';
  25. std::cout << '\n';
  26. }
  27.  
Success #stdin #stdout 0s 2968KB
stdin
Standard input is empty
stdout
8573656 5465467 5435325 3253255