Files
42_EXT_01_dr_quine/3_Sully/Sully.c
2024-01-26 00:13:45 +01:00

9 lines
626 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 *quine = "#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) "s"\nint i = %i;\nMAIN(str(MAIN(s,n)))\n"; char *kid_name; char *temp; asprintf(&temp, quine, 10, 20, 30); asprintf(&kid_name, "Sully_%i.c", 40); FILE *file = fopen(kid_name, "w"); fprintf(file, temp, 50, 60); fclose(file);free(temp);free(kid_name);return 0; }
int i = 5;
MAIN(str(MAIN(s)))