Next:
Human-side C++ syntax
Up:
Pointers
Previous:
Pointers
Contents
Warnings
As already remarked, pointers allow direct access to the computer memory, and hence deliver an enormous power into the programmer's hands.
Pointers allow you to access memory directly, hence can be very dangerous
Attempted memory corruption results in ``segmentation fault'' error and abort, or garbage output, or unpredictable behaviour
Most common dangers:
writing to memory outside bounds
char buffer[] = "LeoLiberti";
char* bufPtr = buffer;
while(*bufPtr != ' ') {
*bufPtr = ' ';
bufPtr++;
}
deallocating memory more than once
Pointer bugs are usually very hard to track
Leo Liberti 2008-01-12