Re: Query: What happens in case of char array overflow?

2012-10-09 Thread davi
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 fo

Re: Query: What happens in case of char array overflow?

2012-10-09 Thread davi
Viresh Kumar wrote: > > struct foo { > > > > char array[5]; > > > > }; > > I am not adding '\0' in my string at all. Is this '\0' always added by > compiler, even in above situation? The compiler does not add the trailing '\0'. It is added only by the string manipulation functi