How do you do a rough check as to what got allocated where in memory?

Note that although this is not enforced by some standard, the address higher lower can be different, though for any sane implmentation, this would be the behavior.

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
 
int contact2[10];
 
int main() {
    int stack_var;
    int *heap_var = malloc(sizeof(int));
 
    char *str = "Hello, World!";
 
    printf("Address of stack_var: %p\n", (void *)&stack_var);
    printf("Address of heap_var: %p\n", (void *)heap_var);
 
    int arr1[] = {1, 2, 3, 4, 5};
    int arr2[] = {6, 7, 8, 9, 10};
 
    int concat[10];
    memcpy(concat, arr1, sizeof(arr1));
    memcpy(concat + sizeof(arr1) / sizeof(arr1[0]), arr2, sizeof(arr2));
 
    memcpy(contact2, arr1, sizeof(arr1));
    memcpy(contact2 + sizeof(arr1) / sizeof(arr1[0]), arr2, sizeof(arr2));
 
    printf("Address of arr1: %p\n", (void *)arr1);
    printf("Address of arr2: %p\n", (void *)arr2);
    printf("Address of concat: %p\n", (void *)concat);
    printf("Address of contact2: %p\n", (void *)contact2);
    printf("Address of str: %p\n", (void *)str);
}

Note that str has the lowest address, followed by the global heap ( it’s actually also in the data segment ) variable, then the inner heap and then the stack variables. Also note that str is not in stack but in the data segment hence the lowest. It is also not modifiable and any modification is undefined behavior.