const char *lines[]= { "#include ", "using namespace std;", "void quote(const char* c)", "{", "%twhile(*c)", "%t{", "%t%tif(c[0]=='%' && c[1]=='q') ++c, cout << '%q';", "%t%telse if(*c == '%' && c[1] == 't') ++c, cout << '%bt';", "%t%telse if(*c == '%' && c[1] == 'b') ++c, cout << '%b%b';", "%t%telse cout << *c;", "%t%t++c;", "%t}", "}", "", "void printData()", "{", "%tcout << %qconst char *lines[]=%bn{%bn%q;", "%tfor(int i = 0; lines[i]; ++i)", "%t%tcout << %q%bt%b%q%q << lines[i] << %q%b%q,%bn%q;", "%tcout << %q%bt0%bn};%bn%q;", "%tcout << %qconst char *intron=%b%q%q << intron << %q%b%q;%bn%q;", "}", "", "void printProgram()", "{", "%tfor(int i = 0; lines[i]; ++i)", "%t{", "%t%tquote(lines[i]);", "%t%tcout << '%bn';", "%t}", "}", "", "void main()", "{", "%tprintData();", "%tprintProgram();", "}", 0 }; const char *intron="Put whatever text you want here"; #include using namespace std; void quote(const char* c) { while(*c) { if(c[0]=='%' && c[1]=='q') ++c, cout << '"'; else if(*c == '%' && c[1] == 't') ++c, cout << '\t'; else if(*c == '%' && c[1] == 'b') ++c, cout << '\\'; else cout << *c; ++c; } } void printData() { cout << "const char *lines[]=\n{\n"; for(int i = 0; lines[i]; ++i) cout << "\t\"" << lines[i] << "\",\n"; cout << "\t0\n};\n"; cout << "const char *intron=\"" << intron << "\";\n"; } void printProgram() { for(int i = 0; lines[i]; ++i) { quote(lines[i]); cout << '\n'; } } void main() { printData(); printProgram(); }