I want to know if this is a memory-safe and that if there is a chance the address could be overwritten (dangling ptr)
#include <iostream>
int main() {
int *ptr;
std::cout << *ptr << std::endl;
{
int x = 5;
ptr = &x;
}
std::cout << *ptr << std::endl;
std::cout << ptr << std::endl;
*ptr = 10;
std::cout << *ptr << std::endl;
std::cout << ptr << std::endl;
std::cout << "Hello, world!";
return 0;
}