Tuesday, December 12, 2006

Fun with programming

Well another interesting piece of code I came across on some website....sorry I forgot the source. But I claim no responsibility or originality of the code....

It is called a quine....
Well quine is a piece of code that outputs itself exaclty.
Search on the net and you will find many more of thses examples. Search for "quine"

Here is the one i liked!
main(){char *c="main(){char *c=%c%s%c;printf(c,34,c,34);}";printf(c,34,c,34);}

Just compile and run the code....and enjoy the beauty of "C programming"

****************************************************************************

Here is another of my favourite fun code in C....
Program without the omni present main()....

// Code to print hello without main()
// compile gcc -nostartfiles filename.c

#include "stdlib.h"
#include "stdio.h"
_start()
{
printf("Hello World\n");
exit(0); // If no exit seg fault "Cannot find bounds of current function"
}

That is all folks...
I might update the page if i find some new interesting things...till then
Happy Coding :)

No comments: