I used to get laughed at for being explicit when I coded C. Some of the
guys in the office said that my C looked like perfectly formed Pascal.....
I spent less time chasing bizarre bugs though!
Doug
On Fri, Oct 14, 2011 at 5:13 PM, Pontus Pihlgren <pontus at update.uu.se>wrote:
On Thu, Oct 13, 2011 at 09:14:34PM +0100, Tony Duell
wrote:
for(int
i=0;i<14;i++)
putchar(i["hello world\n"]);
Not very complex, but figuring out how it works i fun :-)
What's to 'work out'? The argument to putchar looks a bit odd, but IIRC,
A[i] is a shorthand for *(A+i), and addition is commutitive (even when it
involves pointers). So that's just indexing an array of chracters (the
string constant) using i.
Hey Tony, cut me some slack. Not all C programmers will recall(or even
know to begin with) that A[i] is shorthand for *(A+1). I learned it
through this example.
Here is another one which also requires some knowledge of standards:
What is the safe thing to do after a longjmp to a previous setjmp
position?
Regards,
Pontus.