#define _GNU_SOURCE /* for asprintf */ #include /* for free and system */ #include /* for __FILE__ */ #include #define str(s) #s #define xstr(s) str(s) #define FT(s) \ int main() \ { \ if (i <= 0) \ return 0; \ \ char *before = "\ #define _GNU_SOURCE /* for asprintf */\n\ #include /* for free and system */\n\ #include /* for __FILE__ */\n\ #include \n\ #define str(s) #s\n\ #define xstr(s) str(s)\n\ #define FT(s) "; \ char *quine = s; \ char *after = "\ \n\ int i = %i;\n\ char *file_name = __FILE__;\n\ FT(xstr(FT(s)))\n"; \ \ if ((strchr(file_name, '_')) != ((void*)0)) \ i--;\ \ char kid_name_c[42]; \ char after_expanded[42]; \ char cmd[42]; \ \ sprintf(kid_name_c, "Sully_%i.c", i); \ FILE *file = fopen(kid_name_c, "w"); \ \ sprintf(after_expanded, after, i); \ fprintf(file, "%s%s%s", before, quine, after_expanded); \ fclose(file); \ \ sprintf(cmd, "clang Sully_%1$i.c -o Sully_%1$i", i); \ system(cmd); \ \ if (i >= 0) \ { \ sprintf(cmd, "./Sully_%i", i); \ system(cmd); \ } \ \ return 0; \ } int i = 5; char *file_name = __FILE__; FT(xstr(FT(s)))