I am trying to get my feet into C, and wrote this program that displays a kb of my RAM in a random location. Here is the code, and it works fine:
#include
You never initialize mem
, so its contents are undefined. When you attempt to either increment it with ++
or dereference the pointer, you get undefined behavior.
One of the things that can happen with undefined behavior is that a program may appear to work normally, and making a seemingly unrelated change will cause a crash.