Silly programming problems
Blair P. Houghton
bph at buengc.BU.EDU
Wed Mar 22 04:41:23 AEST 1989
In article <2179 at fireball.cs.vu.nl> maart at cs.vu.nl (Maarten Litmaath) writes:
>frisk at rhi.hi.is (Fridrik Skulason) writes:
>\ "write a one line C program that produces the source code
>\ to itself when run."
[...]
"the source code to itself" -- that's what it sez.
>A cheat.
>----------8<----------8<----------8<----------8<----------8<----------
>main(){execlp("cat","",__FILE__,(char*)0);}
>----------8<----------8<----------8<----------8<----------8<----------
Not so big a cheat. It seems it really would produce it's own source,
rather than just a copy or whatever its buggy little self happens to
contain. This way, you are _certain_ that the program is what its
source looks like. Except now you have to keep them together
forever...but it may be the only answer that fits the spec perfectly.
--Blair
"Maybe there should be some
'find' and 'diff' action in
there, just to be sure..."
More information about the Comp.lang.c
mailing list