
"RE: "Re: "RE: Infinite loop ..."
Quote:
>In article 20468 Lars Rasmussen writes:
>=>In article 20435 Rama R. Pakala writes:
>=>`> main(i){while(22-printf("\n%d little %s",i++,i%3?i>9?"indian boys":"":"indians"));}
>=>`> Note, that this is 83-char NON-OBFUSCATED CODE. If you allow me to
>=>`> obfuscate, I'll join the "indian" chars... O.K. ?
>=I came to wonder what your definition of obfuscation is.
>=Surely the use of ??::, 22-printf(.. and the declaration of the variable i
>=in the example above ranks as obfuscation???
>Obfuscation, Lars, is when you're FLUENT IN C, I give you SELF-CONTAINED
>C source code, and you look at it and SCRATCH OUR HEAD like a child :-)
Not really having used the return-value from printf for anything and not
re-reading the printf-manual every so often, I _did_ scratch my head for a
while over the 22-printf(.. :)
I guess my definition of obfuscation is more moderate than yours then.
Quote:
>I can give you such code, if you're not going to feel humiliated :-(
Heh. Nah, I'm familiar with some gross examples ;)
Quote:
>=>DOES printf RETURN-VALUE COUNT the \n as a char or NOT:
>=>Borland C++ DOES - that's why I have put
>=
>=>main(i){while(22-printf...
>=
>=>If your compiler DOES NOT count the "\n" as a char, put
>=>main(i){while(21-printf...
>=
>=Which hardly makes the entry portable ;)
>=So that's two portability-problems in your code. (including i++ in the call)
>Lars, if you consider "++" and "printf" non-portable for the contest, then
>you have to become a lawer :-)
Ungh. It's much more fun finding loopholes in OS's than in dusty lawbooks ;)
Maybe I wasn't clear enough:
A solution having any of the two following 'features' will probably compile
correctly with an ansi-compliant compiler, but the excact behaviour of the
executable will be strongly dependant on the architecture.
1) Increment the variable in the argument list of printf()
From the Ansi-Reference Manual (in K&R):
A7.3.2 Function Calls
[...]
The order of evaluation of arguments is unspecified; take note that
various compilers differ.
[...]
2) Rely on the excact value returned from printf()
(Ie: 22-printf() or 3&printf().)
You pointed at the problem with this yourself.
Quote:
>Make it a great day:
>ZAR Petkov
>__
>phone (412) 241-0862
>Pittsburgh, PA
Regards,
--