www.
linuxforu.
com | LINUX FOR YOU | JANUARY 2007
C M Y K
119
Quines
Write a program that prints the source code of that
program itself (such programs are known as ‘quines’).
The
solution need not be generic; it is enough that the program
written prints...
More
www.
linuxforu.
com | LINUX FOR YOU | JANUARY 2007
C M Y K
119
Quines
Write a program that prints the source code of that
program itself (such programs are known as ‘quines’).
The
solution need not be generic; it is enough that the program
written prints itself.
Note:Note:Note:Note:Note: You should not resort to shortcuts such as fileYou should not resort to shortcuts such as fileYou should not resort to shortcuts such as fileYou should not resort to shortcuts such as fileYou should not resort to shortcuts such as file
I/O operations to open the source file and print theI/O operations to open the source file and print theI/O operations to open the source file and print theI/O operations to open the source file and print theI/O operations to open the source file and print the
contents.
contents.
contents.
contents.
contents.
Here is a well-known and clever solution:
char*f=”char*f=%c%s%c;main(){printf(f,34,f,34,10);}%c”;main()
{printf(f,34,f,34,10);}
The ASCII values for double-quote
Less