fork(1) download
  1. #include <iostream>
  2. #include <string>
  3. using namespace std;
  4.  
  5. struct skipchars
  6. {
  7. string &str;
  8. };
  9.  
  10. istream& operator>>(istream& stream, skipchars 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. int main()
  22. {
  23. string str;
  24. cout << "enter smth:\n";
  25. cin >> skipchars{str};
  26. cout << "entered string: " << str;
  27. return 0;
  28. }
Success #stdin #stdout 0.01s 5516KB
stdin
HelloWorldHowAreYou
stdout
enter smth:
entered string: HelloHowAr