Create a `std::unique_ptr ptr1` containing an integer read from input. Use `std::move` to transfer ownership of the pointer to `ptr2`. Check if `ptr1` is now null; if so, print ‘ptr1 empty’. Then print ‘ptr2: [val]’.
A single integer.
Print the status of both pointers.
None
77
ptr1 empty
ptr2: 77
Because unique_ptrs are exclusive, they cannot be copied. Their ownership must be explicitly 'moved' to another pointer, leaving the original pointer empty.
#include <iostream>
#include <memory>
#include <utility>
int main() {
int val;
if (std::cin >> val) {
// Transfer ownership using std::move and verify
}
return 0;
}Embedded systems rely on efficient low-level programming to interact directly with hardware. In this course, you will learn how to write practical Embedded C programs used in real microcontroller-based systems. Rather than focusing only on theory, this course follows a practice-driven approach. Each lesson includes hands-on coding exercises that simulate real firmware development tasks used