Path: utzoo!mnetor!uunet!seismo!sundc!pitstop!sun!amdcad!ames!nrl-cmf!cmcl2!brl-adm!brl-smoke!gwyn From: gwyn@brl-smoke.ARPA (Doug Gwyn ) Newsgroups: comp.lang.c Subject: Re: Another way (How not to write a loop) Message-ID: <7278@brl-smoke.ARPA> Date: 18 Feb 88 22:27:35 GMT References: <560@naucse.UUCP> <1988Feb11.200149.25172@sq.uucp> <2115@bsu-cs.UUCP> <6848@sol.ARPA> <16982@watmath.waterloo.edu> Reply-To: gwyn@brl.arpa (Doug Gwyn (VLD/VMB) ) Organization: Ballistic Research Lab (BRL), APG, MD. Lines: 14 In article <16982@watmath.waterloo.edu> rbutterworth@watmath.waterloo.edu (Ray Butterworth) writes: -> > auto size_t index; -> > index = sizeof(array) / sizeof(array[0]); -> > while (--index >= 0) -The problem I was trying to point out is that much existing -code wasn't written with perfect style, and this is yet another -way in which otherwise correct code will break when it is ported -to an ANSI compiler (as I found out the hard way). The fact that the result of sizeof has an unsigned integral type is not new with ANSI C. UNIX C has been this way since around 1980 at least. You're getting confused since Berkeley didn't pick up this change when they stole the pre-USG 3.0 C compiler (circa 1979) that is included in their distribution.