← Back to Pointers
Question 688
Heap Allocated Book Record
Heap Allocated Book Record
The Book struct (a string title and an int pages) is already written for you. Allocate exactly ONE Book on the heap holding the title "Dune" and 412 pages, and store its address in the pointer book. The two cout lines that read the members through the pointer are already written. Do NOT create the Book on the stack — it must come from new. Print exactly what is shown in Expected Output. Free the memory you allocate before the program ends — this question checks for memory leaks.
Expected Output:
Title: Dune Pages: 412
= newline. The output ends with a newline — print one after the last line.
Hints2 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.