Wednesday, June 23, 2004

c/c++ :: main(a){a="main(a){a=%c%s%c;printf(a,34,a,34);}";printf(a,34,a,34);}

I didnot know the problem i tried to solve so hard had one line solution. "without success" :(

yes this code will print itself. i was really shocked to see the output of the code. i would had never guessd that it will write its own code.

i did some research, in understanding the code. here it is -

main(a){

a="main(a){a=%c%s%c;printf(a,34,a,34);}";

printf(a,34,a,34);
//printf( "main(a){a=%c%s%c;printf(a,34,a,34);}" , 34, a , 34);

/* both of above commands are equivalent
* the format string in printf is issued as a variable
* (i didnot know that format string can be a variable) -
*
* _________--------- the format string --------____%c__%s_%c_
* printf( "main(a){a=%c%s%c;printf(a,34,a,34);}" , 34, a, 34);
*
* 34 when printed using %c prints " (quote)
*
* really magical ;)
* us ;)
*/

}

nightout at serverroom. worked on opencv after so many days. i am feeling good about that. i am really afraid that jpn wont give me msbr. i didnot meet him for last 2 weeks. i will work hard now. promise.

aslo i didnot call her, after a promise. she will screw me for sure. i dont have any choice, except lieying to her. but need something really solid. i was admitted in hospital.... not good.... how about a friend getting seroius, and admitted to hospital, and had no time to, even didnot eat. why not jayaram, am i lying.