Step 5 of 10
null
NULL is a special pointer value meaning "points at nothing". Dereferencing NULL crashes the program (on a normal OS it's the famous segmentation fault).
Always check a pointer that might be NULL before using it:
if (p != NULL) {
printf("%d\n", *p);
}
Your turn: write int safe_get(const int *p, int fallback) that returns *p, or fallback if p is NULL.
Previous: Pointer arithmetic and arrays Next: Strings through pointers