- wip sully first step ok : decrementing i

- in sully and grace, changed quine string by 3 strings before quine and after
This commit is contained in:
asus
2024-01-26 10:33:42 +01:00
parent 996749c8be
commit b4b3b64444
2 changed files with 2 additions and 2 deletions

View File

@@ -1,7 +1,7 @@
#include <stdio.h> #include <stdio.h>
#define xstr(s) #s #define xstr(s) #s
#define str(s) xstr(s) #define str(s) xstr(s)
#define MAIN(s) int main() { char *quine = "#include <stdio.h>\n#define xstr(s) #s\n#define str(s) xstr(s)\n#define MAIN(s) "s"\n/*\n comment\n*/\nMAIN(str(MAIN(s)))\n"; FILE *file = fopen("Grace_kid.c", "w"); fprintf(file, "%s", quine); fclose(file); return 0; } #define MAIN(s) int main() { char *before = "#include <stdio.h>\n#define xstr(s) #s\n#define str(s) xstr(s)\n#define MAIN(s) "; char *quine = s; char *after = "\n/*\n comment\n*/\nMAIN(str(MAIN(s)))\n"; FILE *file = fopen("Grace_kid.c", "w"); fprintf(file, "%s%s%s", before, quine, after); fclose(file); return 0; }
/* /*
comment comment
*/ */

View File

@@ -3,6 +3,6 @@
#include <stdio.h> #include <stdio.h>
#define xstr(s) #s #define xstr(s) #s
#define str(s) xstr(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; } #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; int i = 5;
MAIN(str(MAIN(s))) MAIN(str(MAIN(s)))