summaryrefslogtreecommitdiff
path: root/reference/C/CONTRIB/SNIP/ansiself.c
blob: 863ee4e4e7595c9816b0afe855f9ec873a7f1cec (plain)
1
2
3
4
5
6
7
8
9
10
/*
**  Challenge: Write the smallest self-duplicating program, not
**  reading the source file, which successfully exits and is strictly
**  conforming Standard C.
**
**  Public domain response by Thad Smith
*/

#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[102],c[1],*c,*c,c,*c,c[1]);exit(0);}