← Back to Pointers
Question 672
Check for nullptr Before You Dereference
Check for nullptr Before You Dereference
Complete the functionreport(int* p): - ifpisnullptr, printNo targetfollowed by a newline - otherwise printTarget:followed by the valueppoints at, then a newlinemainis already written: it callsreportonce with a null pointer and once with the address oflives(which is 3).
Expected Output:
No target Target: 3
= newline. The output ends with a newline — print one after the last line.
Hints4 available
Sign in to use hintsTopics:
Pointers
1
Tab to indent (Esc then Tab to move on) · Ctrl+Enter to run · Shift+Alt+F to format · Ctrl+Space to expand shortcuts (cout, fori)
Your Output
Run your code to see the output here...
Test Cases
Run your code to see test case results.