fork download
  1. #include <iostream>
  2. #include <sstream>
  3. using namespace std;
  4.  
  5. int main() {
  6. stringstream is("{ beforechars [{Object1},{Object2},{Object3}] afterchars }");
  7. string content;
  8.  
  9. std::getline(is, content, '[');
  10. auto pos = is.tellg();
  11. while (std::getline(is,content,'{') && !is.eof()) {
  12. std::getline(is,content,'}');
  13. pos = is.tellg();
  14. std::cout << content << std::endl;
  15. }
  16. is.seekg(pos);
  17. std::getline(is,content);
  18. std::cout<<"FINAL:"<<content<<std::endl;
  19.  
  20. return 0;
  21. }
Success #stdin #stdout 0s 3460KB
stdin
Standard input is empty
stdout
Object1
Object2
Object3
FINAL:] afterchars }