Created
April 19, 2020 21:13
-
-
Save 8051Enthusiast/f456cd52569bd2971ac479bbde41d5ab to your computer and use it in GitHub Desktop.
preprocess with `gcc -E -std=c99 quine.c -o quine.i` and compile with `gcc -std=gnu99 quine.i -o 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> | |
| #ifdef A | |
| R"(" | |
| #else | |
| #define A | |
| const char *s = | |
| #include __FILE__ | |
| ; | |
| #undef A | |
| #endif | |
| int main() { | |
| char* pre = "#include <stdio.h>\n#ifdef A\nR\"(\"\n#else\n#define A\nconst char *s =\n#include __FILE__\n;\n#undef A\n#endif\n"; | |
| char* post = "#ifdef A\n\")\"\n#endif\n"; | |
| printf("%s%.235s%s",pre,s+9,post); | |
| return 0; | |
| } | |
| #ifdef A | |
| ")" | |
| #endif |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment