Created
July 19, 2020 09:21
-
-
Save chaidhat/9920e9ae052593e32dbb38ccd5367333 to your computer and use it in GitHub Desktop.
self replicating code, inspired by https://cs.lmu.edu/~ray/notes/quineprograms/
This file contains 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> | |
int main () { | |
char *dat = "#include <stdio.h>%cint main () {%c%cchar *dat=%c%s%c;%c%cprintf(dat,10,10,9,34,dat,34,10,9,10);%c}"; | |
printf(dat,10,10,9,34,dat,34,10,9,10); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
information is stored in the char *dat which is then printed out with the printf() function. The information inside dat is exactly what is printed out. Use of %c is to substitute line breaks, tabs, quotation marks. Dat inserts itself into itself.
ASCII 9 - tab
ASCII 10 - line break
ASCII 34 -
"