Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!rutgers!uwvax!tank!mimsy!chris From: chris@mimsy.UUCP (Chris Torek) Newsgroups: comp.lang.c Subject: Re: Correction, a[33] Message-ID: <17763@mimsy.UUCP> Date: 26 May 89 11:21:00 GMT References: <5819@microsoft.UUCP> Distribution: usa Organization: U of Maryland, Dept. of Computer Science, Coll. Pk., MD 20742 Lines: 39 In article <5819@microsoft.UUCP> t-iaind@microsoft.UUCP (Iain Davidson) writes: >char a[33] > >is not an array of 33*sizeof (int) This much is true (it is size 33*sizeof(char), or 33) ... >but really 34 slots !!!!! > >Remember C is start base 0 not 1. > >0..33 = 34 slots of int's. > >char a[9] holds 10 characters !!!! C is not BASIC. `char a[9]' holds nine characters, numbered a[0] through a[8] inclusive. (Actually, BASICs tend not to be consistent about allowing a[0].) And people wonder why microsoft's compilers are buggy :-) Actually, there is a grain of truth in all this. Given an array declaration type-name array-name '[' integral-constant-expression ']' ';' or T a[N]; the address &a[N] must be computable. This sometimes means that array objects need an extra byte---so that int b[K]; actually sets aside K*sizeof(int)+1 bytes, rather than just K*sizeof(int). -- In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7163) Domain: chris@mimsy.umd.edu Path: uunet!mimsy!chris