#include #include #include int main(void) { int stack_val = 42; printf("Allocated on stack: %d\n", stack_val); int *heap_val = (int *)malloc(sizeof(int)); if (heap_val == NULL) { printf("Heap allocation failed\n"); return 1; } *heap_val = 99; printf("Allocated on heap: %d\n", *heap_val); const char *original = "OSTEP"; char *copy = (char *)malloc(strlen(original) + 1); if (copy == NULL) { free(heap_val); printf("String allocation failed\n"); return 1; } strcpy(copy, original); printf("String copy: %s\n", copy); free(copy); free(heap_val); printf("All heap memory released\n"); return 0; }