Does anyone know exactly what happens when you define an array? I'm asking this, because (in Linux) I don't always get Segmentation Faults, when I would normally expect one. For example:
char s[25];
s[400] = 0;
s[-5] = 0;
With that, I don't think that I got any errors running the program. I expected to get a Segmentation Fault, but I didn't.
Here's another thing that I found kind of strange:
char *s = "Hi there";
That statement works just fine (no errors), but when I try to do this:
*s = 0;
it will give me a segmentation fault. Can anyone explain this stuff to me? Thanks in advance.
char s[25];
s[400] = 0;
s[-5] = 0;
With that, I don't think that I got any errors running the program. I expected to get a Segmentation Fault, but I didn't.
Here's another thing that I found kind of strange:
char *s = "Hi there";
That statement works just fine (no errors), but when I try to do this:
*s = 0;
it will give me a segmentation fault. Can anyone explain this stuff to me? Thanks in advance.