Created
September 5, 2016 20:01
-
-
Save sortie/f78f43c7197d84ee90e346bae4d8510c to your computer and use it in GitHub Desktop.
quine
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <stdio.h> | |
| static const char code[] = | |
| "#include <stdio.h>\n" | |
| "\n" | |
| "static const char code[] =\n" | |
| " \"\0\";\n" | |
| "\n" | |
| "int main(void) {\n" | |
| " for (size_t i = 0; i < sizeof(code) - 1; i++) {\n" | |
| " if (code[i] == '\\0') {\n" | |
| " for (size_t j = 0; j < sizeof(code) - 1; j++) {\n" | |
| " if (code[j] == '\\0')\n" | |
| " printf(\"\\\\0\");\n" | |
| " else if (code[j] == '\\\\')\n" | |
| " printf(\"\\\\\\\\\");\n" | |
| " else if (code[j] == '\"')\n" | |
| " printf(\"\\\\\\\"\");\n" | |
| " else if (code[j] == '\\n')\n" | |
| " printf(\"\\\\n\\\"\\n \\\"\");\n" | |
| " else\n" | |
| " putchar((unsigned char) code[j]);\n" | |
| " }\n" | |
| " } else {\n" | |
| " putchar((unsigned char) code[i]);\n" | |
| " }\n" | |
| " }\n" | |
| " return 0;\n" | |
| "}\n" | |
| ""; | |
| int main(void) { | |
| for (size_t i = 0; i < sizeof(code) - 1; i++) { | |
| if (code[i] == '\0') { | |
| for (size_t j = 0; j < sizeof(code) - 1; j++) { | |
| if (code[j] == '\0') | |
| printf("\\0"); | |
| else if (code[j] == '\\') | |
| printf("\\\\"); | |
| else if (code[j] == '"') | |
| printf("\\\""); | |
| else if (code[j] == '\n') | |
| printf("\\n\"\n \""); | |
| else | |
| putchar((unsigned char) code[j]); | |
| } | |
| } else { | |
| putchar((unsigned char) code[i]); | |
| } | |
| } | |
| return 0; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment