#include <stdio.h>
#include <stdlib.h>
int main() {
int* ptr = malloc(sizeof(int)); // Allocate memory
*ptr = 42; // Assign a value
printf("Value: %d\n", *ptr);
free(ptr); // Free the memory
*ptr = 50; // Dangling pointer access
printf("Value: %d\n", *ptr); // Undefined behavior
return 0;
}