Viresh Kumar wrote: > When we have following declaration: > > struct foo { > char array[5]; > .... > }; > > And have a definition like: > > struct foo foo_abc = { > .array = "12345", > }; > > Problem here is: size of array is 5 bytes and so we can actually add a > string with four characters only to it, as '\0' will take > an additional space. > > But with my definition of foo_abc.. i had 5 characters + '\0'... that > will make it 6 and that will overflow the array.. > > What will actually happen here? > - compiler will not add '\0' at all? > - or it will go outside of boundaries of array?
I think it will go outside of boundaries. You should avoid adding the \0 or redefine char array to hold up to 6 chars. Regards _______________________________________________ linaro-toolchain mailing list linaro-toolchain@lists.linaro.org http://lists.linaro.org/mailman/listinfo/linaro-toolchain