Tuesday, July 19, 2011

Quine in C

A quine is a computer program which takes no input and produces a copy of its own source code as its only output.
The idea of self-reproducing programs first appeared in Paul Bratley and Jean Millo's article "Computer Recreations: Self-Reproducing Automata" in 1972. Bratley first became interested in self-reproducing programs after seeing the first known such program written in Atlas Autocode at Edinburgh in the 1960s by the University of Edinburgh lecturer and researcher Hamish Dewar. 
Source:en.wikipedia.org 
Here's a cute quine by me: 
#include<stdio.h>
void main() { char p[]="#include <stdio.h> void main() { char p[]=%c%s%c; printf(p,34,p,34);}";
printf(p,34,p,34);} //The 34 in decimal is for the double quotes.;-)

Output:
Same as the code. But in one line.Enjoy!!!

No comments:

Post a Comment