here is the smallest code that output itself. But can't grasp how this works. can somebody explain?
main(a){printf(a,34,a="main(a){printf(a,34,a=%c%s%c,34);}",34);}
I bet it won't work on a 64-bit platform unless its model is ILP64 (64-bit int
s), because it relies on int
being big enough to contain a char*
.
It declares a variable a
that contains a copy of the code minus the string itself, and uses printf()'s formatting codes to output both the code and the string. Do you need more details?