Self generating code

Home
Programming resources

Warning: Trying to understand the follwoing can cause a lot of white hairs. You have been forewarned.

Author: Unknown (from The Jargon File)

main(){char *c="main(){char *c=%c%s%c;printf(c,34,c,34);}";printf(c,3
4,c,34);}

Author: Dario Dariol
main(a){printf(a="main(a){printf(a=%c%s%c,34,a,34);}",34,a,34);}

Author: Thad Smith
Notes: The author claims that this one is strict ANSI. 
#include < stdio.h >
main(){char*c="\\\"#include <stdio.h > %cmain(){char*c=%c%c%c%.102s%cn%c
;printf(c+2,c[102],c[1],*c,*c,c,*c,c[1]);exit(0);}\n";printf(c+2,c[10
2],c[1],*c,*c,c,*c,c[1]);exit(0);}


Home
Programming resources

 

Hosted by www.Geocities.ws

1