Re: odd behavior with Character Arrays

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Aug 8, 2008 at 12:24 PM, Mateusz Loskot <mateusz@xxxxxxxxxx> 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

[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux