[ale] This is legal C:

Bob Toxen bob at verysecurelinux.com
Fri Feb 13 12:01:29 EST 2004


Of more use would be:

main(int argc, char **argv)
{
	int	j	=2;

	printf("Test: %c\n", "heck"[j]);
	exit(0);	/* Not all systems handle return 0; correctly. */
}

or for people who want good English (but not related to indices):

main(int argc, char **argv)
{
	int	j	=2;

	printf("We have %d item%s\n",
	  j, j == 1 ? "s" : "");
	exit(0);	/* Not all systems handle return 0; correctly. */
}


On Thu, Feb 12, 2004 at 10:40:09AM -0500, Bjorn Dittmer-Roche wrote:
> Someone sent me this. It's an interesting oddity. Try it on your
> favorite C compiler!

> 	bjorn

> --------------------------------------------------

> /* Find the strangeness! Spotted on kuro5hin... */
> #include <stdio.h>

> char *foo[] = {"what", "the", "heck", "is", "this"};

> int main(int argc, char **argv)
> {
>   int j=2;
>   printf("Test: %s\n", j[foo]);
>   return 0;
> }



More information about the Ale mailing list