May 2002
Beginner
320 pages
6h 18m
English
Remember that the compiler doesn't care if you try to get or put the value of an element that is outside an array's size. This is because arrays are really convenient shorthand for pointers.
Pointers are just as dangerous as arrays for the same reasons. Have a look at this:
char *SomePointer; *SomePointer = 'x'; // Oops.
What do you think this does? If you answer, “I don't know,” you're right. The behavior of a program with an uninitialized pointer is undefined and unpredictable.
char *SomePointer = NULL; *SomePointer = 'x'; // Oops.
In this case, NULL means “points to nothing.” If you are lucky, the program stops. If you are unlucky, your entire system may freeze or crash. Still, NULL is often used to indicate that ...
Read now
Unlock full access