array refs

Robbert van Renesse cogito at tjalk.UUCP
Sun Jan 13 22:29:52 AEST 1985


In article <7225 at brl-tgr.ARPA> cottrell at nbs-vms.ARPA writes:
>/*
>i disagree about referencing arrays 'out of bounds'. i have often taken
>a pointer, moved it down the array, when suddenly i find i have to
>pervert the previous character. what do i do? something like: p[-1] = ... ;

I see nothing wrong with negative indexing either, on the contrary, it
is very useful when you want to have all the arguments of main in one
string:

	main(argc, argv)
	char *argv[];
	{
		register i;

		for (i = 2; i < argc; i++)
			argv[i][-1] = ' ';
		do_it(argv[1]);
	}

What did you say? Portability? Don't be a bore.
-- 
			Robbert van Renesse
			...!{decvax|philabs|seismo}!mcvax!vu44!cogito



More information about the Comp.lang.c mailing list