A
Anitha
Hi
I observed something while coding the other day:
if I declare a character array as char s[0], and try to use it as any
other character array..it works perfectly fine most of the times. It
holds strings of any length. I guess what is happening here is that
this array initially holds only '\0' and hence is of length 1.
But sometimes, when I tried to write some functions and do some
manipulations on such character arrays, the behavior is erratic..they
result in segmentation fault sometimes,when I try to store certain
values.
I am not able to understand why these arrays are behaving like
this..can you explain how these arrays grow and what could be
happening?
Thanks
Anitha
I observed something while coding the other day:
if I declare a character array as char s[0], and try to use it as any
other character array..it works perfectly fine most of the times. It
holds strings of any length. I guess what is happening here is that
this array initially holds only '\0' and hence is of length 1.
But sometimes, when I tried to write some functions and do some
manipulations on such character arrays, the behavior is erratic..they
result in segmentation fault sometimes,when I try to store certain
values.
I am not able to understand why these arrays are behaving like
this..can you explain how these arrays grow and what could be
happening?
Thanks
Anitha