Files
SnakeAppleSecurityFiles/III. Checksec/custom/heap_example.c
Karmaz95 dec6d69edc
2024-01-06 22:06:00 +01:00

24 lines
449 B
C

#include <stdio.h>
#include <stdlib.h>
int main() {
// Allocate memory on the heap
char *heapMemory = (char *)malloc(100 * sizeof(char));
if (heapMemory == NULL) {
fprintf(stderr, "Memory allocation failed.\n");
return 1;
}
printf("Memory allocated. Press Enter to exit.\n");
// Wait for Enter key press
while (getchar() != '\n');
// Free allocated memory
free(heapMemory);
return 0;
}