fork download
  1. #include <iostream>
  2. #include <string>
  3. #include <sstream>
  4.  
  5.  
  6. std::string Indent(std::string s)
  7. {
  8. std::string result;
  9.  
  10. std::istringstream iss(s);
  11.  
  12. for (std::string line; std::getline(iss, line); )
  13. {
  14. result += " " + line + "\n";
  15. }
  16.  
  17. return result;
  18. }
  19.  
  20.  
  21. int main() {
  22. std::string in;
  23. in += "<region>test\n";
  24. in += " <left>3</left>\n";
  25. in += " <right>4</right>\n";
  26. in += "</region>\n";
  27.  
  28. std::string out;
  29. out += "<texture>lel\n";
  30. out += Indent(in);
  31. out += "</texture>\n";
  32.  
  33. printf("%s\n", out.c_str());
  34. return 0;
  35. }
Success #stdin #stdout 0s 15240KB
stdin
Standard input is empty
stdout
<texture>lel
  <region>test
    <left>3</left>
    <right>4</right>
  </region>
</texture>