- The asterisk(*) notation used to declare pointer variables does not distribute to all variable names in a declaration. Each pointer must be declared with the * prefixed to the name. Eg: int *x,*y;
- Dereferencing a pointer that has not been properly initialized or that has not been assigned to point to a specific location in memory is an error. This could cause a fatal execution time error, or it could accidently modify important data and allow the program to run to completion with incorrect result.
- Being unaware that a function is expecting pointers as arguments for pass-by-reference and passing arguments by value. Some compilers take the values assuming they're pointers and dereference the values as pointers. At run time, memory-access violation or segmentation faults are often generated. Other compilers catch the mismatch in types between arguments and parameters and generate error messages.
- Using pointer arithmetic on a pointer that does not refer to an element in an array.
- Subtracting or comparing two pointers that do not refer to elements in the same array.
- Running off either end of an array when using pointer arithmetic.
- Assigning pointer of one type to a pointer of another type if neither is of type void * is a syntax error.
- Dereferencing a void * pointer is a syntax error.
- Attempting to modify an array name with pointer arithmetic is a compilation error.
More Informative Posts: