From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 23413 invoked by alias); 8 Aug 2008 07:07:35 -0000 Received: (qmail 23211 invoked by uid 22791); 8 Aug 2008 07:07:29 -0000 X-Spam-Check-By: sourceware.org Received: from ti-out-0910.google.com (HELO ti-out-0910.google.com) (209.85.142.188) by sourceware.org (qpsmtpd/0.31) with ESMTP; Fri, 08 Aug 2008 07:06:37 +0000 Received: by ti-out-0910.google.com with SMTP id i7so491523tid.20 for ; Fri, 08 Aug 2008 00:06:34 -0700 (PDT) Received: by 10.110.47.17 with SMTP id u17mr5281244tiu.46.1218179194176; Fri, 08 Aug 2008 00:06:34 -0700 (PDT) Received: by 10.110.109.10 with HTTP; Fri, 8 Aug 2008 00:06:34 -0700 (PDT) Message-ID: Date: Fri, 08 Aug 2008 09:38:00 -0000 From: "Rohit Arul Raj" To: "Mateusz Loskot" Subject: Re: odd behavior with Character Arrays Cc: gcc-help In-Reply-To: <489BEDB7.2020905@loskot.net> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <489BEDB7.2020905@loskot.net> Mailing-List: contact gcc-help-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-help-owner@gcc.gnu.org X-SW-Source: 2008-08/txt/msg00069.txt.bz2 On Fri, Aug 8, 2008 at 12:24 PM, Mateusz Loskot wrote: > Rohit Arul Raj wrote: >> >> 2. Can i get more details as to why if the size of the array is not >> provided the compiler does not insert an string terminator at the end >> of the array. > > How could that be? > It is an array but not a string literal, so compiler does not append \0 or > any other extra elements to it. > > Best regards > -- > Mateusz Loskot, http://mateusz.loskot.net > Charter Member of OSGeo, http://osgeo.org > Hi, If i give the size of the array as 15, like "unsigned char n[15] = {'a', 'b', 'c','d'};" , then it is appending '\0'. But if the size of the array is not given "unsigned char n[] ", then it is not appending '\0'. Does that mean, that if the size of the array is specified, it appends '\0' and if it is not specified then it does not append '\0'? Can you/anyone clarify this point? Regards, Rohit