9 lines
720 B
C
9 lines
720 B
C
#define _GNU_SOURCE /* for asprintf */
|
|
#include <stdlib.h> /* for free */
|
|
#include <stdio.h>
|
|
#define xstr(s) #s
|
|
#define str(s) xstr(s)
|
|
#define MAIN(s) int main() { char *before = "#define _GNU_SOURCE /* for asprintf */\n#include <stdlib.h> /* for free */\n#include <stdio.h>\n#define xstr(s) #s\n#define str(s) xstr(s)\n#define MAIN(s) "; char *quine = s; char *after = "\nint i = %i;\nMAIN(str(MAIN(s)))\n"; i--;char *kid_name; asprintf(&kid_name, "Sully_%i.c", i); FILE *file = fopen(kid_name, "w"); char *decremented_after; asprintf(&decremented_after, after, i); fprintf(file, "%s%s%s", before, quine, decremented_after); fclose(file);free(decremented_after);free(kid_name);return 0; }
|
|
int i = 5;
|
|
MAIN(str(MAIN(s)))
|