DEREFERENCING THE NULL POINTER One of the most common pointer errors is writing
ID: 3859424 • Letter: D
Question
DEREFERENCING THE NULL POINTER One of the most common pointer errors is writing the expression *p or p-> when the value of the pointer p is the null pointer. This must always be avoided because the null pointer does not point to anything. Therefore, when p is the null pointer, *p (which means "the thing that p points to") is meaningless. In this case, p-> is also meaningless. Because the asterisk in *p is called the dereferencing operator, we can state this rule: Never dereference the null pointer. Accidental dereferencing of the null pointer is sometimes a hard error to track down. The error does not cause a syntax error. Instead, when the program is running, there will be an attempt to interpret the null pointer as if it were a valid address. Sometimes this causes an immediate run-time error with a message such as "Address protection violation" or "Bus error, core dumped." But on other machines, the null address might be a valid address, causing your program to read or write an unintended memory location. Often this memory location is part of the machine's operating system, resulting in part of the operating system being cor- rupted. At some later point, perhaps after your program has completed, the cor- rupted operating system can cause an error. Fortunately, restarting your machine usually writes a fresh copy of the operating system into memory but even so, never dereference the null pointer!Explanation / Answer
There are no definite problem one can say it might happen while dereferecing the null pointer.It may cause many problems but it won't say as syntax error and mostly won't be considered during compilation or as compile time error.so there are 2 main cases which can be determined as or during run time error or run time respectively.
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.