Create a `std::shared_ptr sp` based on input. Assign it to a `std::weak_ptr wp`. A weak_ptr does not increase the reference count. Call `wp.lock()` to temporarily access the shared resource. If successful, print ‘Locked: [val]’.
A single integer.
Print the retrieved value via lock().
None
99
Locked: 99
Weak pointers break circular references by observing a shared_ptr without claiming ownership. To use the data, you must 'lock' it to ensure it hasn't been destroyed.
#include <iostream>
#include <memory>
int main() {
int val;
if (std::cin >> val) {
// Implement weak_ptr lock logic
}
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