Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <cstdio>
- #include <string>
- const char* escape(std::string v)
- {
- std::string r = "";
- for (int i = 0; i < v.size(); i++)
- if (v[i] == '\n')
- r += "\\n";
- else if (v[i] == '\t')
- r += "\\t";
- else
- r += v[i];
- return r.c_str();
- }
- int main()
- {
- std::string s = "#include <cstdio>\n#include <string>\n\nconst char* escape(std::string v)\n{\n\tstd::string r = %c%c;\n\tfor (int i = 0; i < v.size(); i++)\n\t\tif (v[i] == '%cn')\n\t\t\tr += %c%c%cn%c;\n\t\telse if (v[i] == '%ct')\n\t\t\tr += %c%c%ct%c;\n\t\telse\n\t\t\tr += v[i];\n\treturn r.c_str();\n}\n\nint main()\n{\n\tstd::string s = %c%s%c;\n\n\tprintf(s.c_str(),34,34,92,34,92,92,34,92,34,92,92,34,34,escape(s),34);\n\treturn 0;\n}";
- printf(s.c_str(),34,34,92,34,92,92,34,92,34,92,92,34,34,escape(s),34);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement