I\'m trying to get to grips with malloc
, and so far I\'m mostly getting unexpected results when testing and playing around with it.
int main(int arg
The codes runs without an error, but it is still wrong. You just do not notice it. Your loop runs out of the allocated area, but the system remains unaware of that fact until you run out of a much larger area your program can potentially access.
Picture it this way:
1234567890
Your 10 int
s are in the middle of other data, which you can read and even write - to very unpleasant effects. C is not holding your hand here - only once you go out of the total available memory, the program will crash, not before.