61. unique_ptr Ownership Consume

In modern C++, function signatures communicate ownership intent.
A function that takes ownership of a resource must make that intent explicit in its parameter type.

You are given a program where a buffer is managed by std::unique_ptr.
The buffer must be consumed by a function, meaning ownership transfers to the function and the caller must no longer own it.

Your task is to fix the function API and the call site so that ownership transfer is explicit and correct.

This problem is about API design, not mechanics.

Program Flow:

  1. Read N
  2. Create a unique_ptr that owns a buffer of N bytes
  3. Call a function that consumes the buffer
  4. The function prints the buffer
  5. After the call, the caller must have no ownership

Example Input:

4
10 20 30 40

Example Output:

10 20 30 40
No data 

Constraints:

  • N ranges from 1 to 100
  • Ownership must be transferred to the function
  • The function must clearly express ownership transfer in its signature
  • Output format must match exactly

 

 

 

Loading...

Input

4 10 20 30 40

Expected Output

10 20 30 40 No data