Path: utzoo!attcan!utgpu!watmath!rbutterworth From: rbutterworth@watmath.waterloo.edu (Ray Butterworth) Newsgroups: comp.lang.c Subject: Re: pointers to arrays Message-ID: <23792@watmath.waterloo.edu> Date: 20 Feb 89 16:47:30 GMT References: <19784@uflorida.cis.ufl.EDU> <227300001@uxa.cso.uiuc.edu> Organization: U of Waterloo, Ontario Lines: 46 In article <227300001@uxa.cso.uiuc.edu>, fso10235@uxa.cso.uiuc.edu writes: > In your example, you state that E is an "array" and > then go on to talk about &E. > E is actually an address itself; it is the address > of the first element of the array. Putting brackets > after any number merely dereferences to that number > plus what is in the brackets. > This is in K&R, I believe. extern int E[10]; E is NOT an address. E is NOT a pointer. E IS an array. E is exactly what it looks like. In certain contexts however, where it is illegal to use an array, the compiler will interpret E as &E[0] to save four keystrokes for the programmer. This may or may not have been a good idea. There certainly has been a lot more than four keystrokes wasted on the net by people arguing about this unnecessary confusion. Similarly: NULL is NOT a null pointer. NULL is possibly NOT a pointer at all. NULL is NOT part of the C language. NULL IS a mistake. NULL can be correctly defined as 0 on all valid C compilers. The identifier is there simply as a comment to the programmer to indicate that he is working with a pointer. Too many programmers think that the compiler can understand this comment. Too many compiler maintainers think that they are helping their confused programmers by defining incorrect values for NULL in the hope that some of the incorrect code will compile correctly. NULL is a definite mistake. It looks like it means more than it really does. It belongs with BREAK_LOOP, BREAK_SWITCH, and other such well-intentioned but misleading macros. It should either have never been introduced, or it should have been defined as part of the language. NULL is a mistake. Don't use it.