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.