fork download
  1. #include <iostream>
  2. #include <string>
  3. using namespace std;
  4.  
  5. struct skipcharsHelper
  6. {
  7. string &str;
  8. };
  9.  
  10. istream& operator>>(istream& stream, skipcharsHelper output)
  11. {
  12. string temp;
  13. if (stream >> temp) {
  14. for (size_t i = 0; i < temp.size(); i += 10) {
  15. output.str += temp.substr(i, 5);
  16. }
  17. }
  18. return stream;
  19. }
  20.  
  21. skipcharsHelper skipchars(string &str)
  22. {
  23. return skipcharsHelper{str};
  24. }
  25.  
  26. int main()
  27. {
  28. string str;
  29. cout << "enter smth:\n";
  30. cin >> skipchars(str);
  31. cout << "entered string: " << str;
  32. return 0;
  33. }
Success #stdin #stdout 0.01s 5316KB
stdin
HelloWorldHowAreYou
stdout
enter smth:
entered string: HelloHowAr