-
Notifications
You must be signed in to change notification settings - Fork 0
/
ouroboros.c
47 lines (45 loc) · 996 Bytes
/
ouroboros.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#include <stdio.h>
#include <string.h>
static void quine(char *s) {
printf("%s(\"\\\n", s);
while (*s != '\0') {
switch (*s) {
case '"':
case '\\':
printf("\\");
break;
case '\n':
printf("\\n\\");
break;
}
printf("%c", *s++);
}
printf("\"\n );\n return 0;\n}\n");
}
int main() {
quine("\
#include <stdio.h>\n\
#include <string.h>\n\
\n\
static void quine(char *s) {\n\
printf(\"%s(\\\"\\\\\\n\", s);\n\
while (*s != '\\0') {\n\
switch (*s) {\n\
case '\"':\n\
case '\\\\':\n\
printf(\"\\\\\");\n\
break;\n\
case '\\n':\n\
printf(\"\\\\n\\\\\");\n\
break;\n\
}\n\
printf(\"%c\", *s++);\n\
}\n\
printf(\"\\\"\\n );\\n return 0;\\n}\\n\");\n\
}\n\
\n\
int main() {\n\
quine"
);
return 0;
}