From: "Luiz Fernando N. Capitulino" Subject: Re: array size 1 ? All headers Date: Tue, 20 Jul 2004 23:57:13 -0300 Sender: linux-c-programming-owner@vger.kernel.org Message-ID: <20040720235713.4cb83b20.lcapitulino@terra.com.br> References: <20040721015338.M80608@sni.ph> Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <20040721015338.M80608@sni.ph> List-Id: Content-Type: text/plain; charset="us-ascii" To: Gre Taguran Cc: linux-c-programming@vger.kernel.org Hi Gre, Em Wed, 21 Jul 2004 10:27:35 +0800 "Gre Taguran" screveu: | i think its not array of 1 but instead array of 2 which is 0 and 1 index. Wrong. K&R defines array as: array[lenght] So, if you defines an array as: int luiz[10] You will have 10 memory cells for it, and if you do: int luiz[1] You will have one memory cell. But, the _access_ is made from 0, so for the first example, we have: luiz[0], luiz[1], luiz[2]... luiz[9]. For the second, just: luiz[0]. | maybe | it is because u were thinking that the last array index (in this case is 1) is | null, but it is only applicable when handling string because string needs a | terminated string. ex. | | char tst[1]; | tst[0]='g'; | tst[1]='r'; | printf("%s",tst); //this would print gr