Quine
30/1/2010 - 21:11:11 - 0 comments - By D47
My new favorite scrabble word is quine. A quine is a program that can print it's own source code. Here is a basic one I wrote just now:

#include <stdio.h>

char *str = "#include <stdio.h>%c%cchar *str = %c%s%c;%c%cint main(void) {%c%cprintf(str, 10, 10, 34, str, 34, 10, 10, 10, 9, 10, 10);%c}%c";

int main(void) {
    printf(str, 10, 10, 34, str, 34, 10, 10, 10, 9, 10, 10);
}


This is just about the most awesome thing I've seen all week.
 
 
Post Comment:
Name:
Message:
Captcha: captcha
 
 

By Dylan McGannon. Feel free to copy, use and modify anything you find here.

Valid HTML 4.01 Strict / Valid CSS!