#include "stdio.h"
#define M(Code) main(){FILE* fp = fopen("source.c", "w");fprintf(fp,"#include \"stdio.h\"\n#define M(Code) %s\nM(%s)\n",#Code,#Code);fclose(fp);}
M(main(){FILE* fp = fopen("source.c", "w");fprintf(fp,"#include \"stdio.h\"\n#define M(Code) %s\nM(%s)\n",#Code,#Code);fclose(fp);})
This is a pretty cute program if I can say so myself. When its ran it will create a file called source.c that will be exactly the same as the code above. You could even recompile source.c and it will create another source.c. You should attempt to do this on your own to see if you can come up with other cool ways of doing it.
Download: SelfRep.c
No comments:
Post a Comment