ahox
-
C,
pasted
on Sep 17:
|
void print(char *s){
char *t;
t=s;
do{
if(*t==0x40){
do{
if(*s==0x22) printf("%c%c",0x5c,0x22);
else if(*s==0x5c) printf("%c%c",0x5c,0x5c);
else if(*s==0x0a) printf("%c%c%c%c%c",0x5c,'n',0x22,0x0a,0x22);
else printf("%c",*s);
} while(*(++s));
}
else printf("%c",*t);
} while(*(++t));
}
int main(void){
char code[] =
"void print(char *s){\n"
" char *t;\n"
" t=s;\n"
" do{\n"
" if(*t==0x40){\n"
" do{\n"
" if(*s==0x22) printf(\"%c%c\",0x5c,0x22);\n"
" else if(*s==0x5c) printf(\"%c%c\",0x5c,0x5c);\n"
" else if(*s==0x0a) printf(\"%c%c%c%c%c\",0x5c,'n',0x22,0x0a,0x22);\n"
" else printf(\"%c\",*s);\n"
" } while(*(++s));\n"
" }\n"
" else printf(\"%c\",*t);\n"
" } while(*(++t));\n"
"}\n"
"int main(void){\n"
" char code[] = \n"
"\"@\";\n"
" print(code);\n"
" return 0;\n"
"}";
print(code);
return 0;
}
|
Output:
|
void print(char *s){
char *t;
t=s;
do{
if(*t==0x40){
do{
if(*s==0x22) printf("%c%c",0x5c,0x22);
else if(*s==0x5c) printf("%c%c",0x5c,0x5c);
else if(*s==0x0a) printf("%c%c%c%c%c",0x5c,'n',0x22,0x0a,0x22);
else printf("%c",*s);
} while(*(++s));
}
else printf("%c",*t);
} while(*(++t));
}
int main(void){
char code[] =
"void print(char *s){\n"
" char *t;\n"
" t=s;\n"
" do{\n"
" if(*t==0x40){\n"
" do{\n"
" if(*s==0x22) printf(\"%c%c\",0x5c,0x22);\n"
" else if(*s==0x5c) printf(\"%c%c\",0x5c,0x5c);\n"
" else if(*s==0x0a) printf(\"%c%c%c%c%c\",0x5c,'n',0x22,0x0a,0x22);\n"
" else printf(\"%c\",*s);\n"
" } while(*(++s));\n"
" }\n"
" else printf(\"%c\",*t);\n"
" } while(*(++t));\n"
"}\n"
"int main(void){\n"
" char code[] = \n"
"\"@\";\n"
" print(code);\n"
" return 0;\n"
"}";
print(code);
return 0;
}
|
|